IEX - char printing - odd behavior

in iex [[1]] is printed as [[1]] however
[[9]] is shown as [’\t’]

Why is that? What am I to do if it needs to be shown as [[9]]

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]]

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.


In iex you can do:

iex(4)> i([9])
Data type
  This is a list of integers that is printed as a sequence of characters
  delimited by single quotes because all the integers in it represent printable
  ASCII characters. Conventionally, a list of Unicode code points is known as a
  charlist and a list of ASCII characters is a subset of it.
Raw representation
Reference modules
Implemented protocols
  Collectable, Enumerable, IEx.Info, Inspect, Jason.Encoder, List.Chars, Phoenix.HTML.Safe, Phoenix.Param, Plug.Exception, String.Chars