I’m playing around with Enum and when I came upon Enum.chunk, I noticed when it comes to listing out integers past 6, I start to get their ASCII values.
twelve = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[1, 2], [3, 4], [5, 6], ‘\a\b’, ‘\t\n’, ‘\v\f’]
Is there any way to escape this so it displays integers?
This has nothing to do with Enum.chunk. It’s a core ambiguity in lists of integers. They really are integers in your data structure, but are just being printed as characters. You can use an option to Kernel.inspect/2 to never display as characters lists.
inspect(Enum.chunk(twelve, 2), char_lists: false)
@blanc11 by default iex will attempt to infer if a list of integers is an Erlang string/charlist. You can disable this behaviour with
iex> IEx.configure inspect: [char_lists: :as_lists]