IEX - char printing - odd behavior

IEx is “helpfully” interpreting your [9] as a character list. To prevent printing it like that when using IO.inspect, you can specify the behaviour: IO.inspect([[9]], charlists: :as_lists).

To make this the default in your current IEx shell, you can use IEx.configure: IEx.configure(inspect: [charlists: :as_lists])

Then it will be printed like this:

iex(8)> [[9]]
[[9]]

To persist that setting so that it is applied every time you open the shell, you can create a file in your project (or your home directory, depending on where you want it to be applied) called .iex.exs and put the configuration call above into it.

See the docs for configuring the shell, .iex.exs, and inspect options for more information.

14 Likes