Hi,
I’m just learning elixir and following the basics of Elixir School’s lessons I found something that shocked me. Please take this dumb example:
iex(33)> Enum.chunk_by([1, 2, 3, 4, 5, 6, 7], fn(x) -> rem(x, 2) == 0 end)
I expected it to return a list of one single item lists, like in [[1], [2], [3], [4], [5], [6], [7]]
but instead I got
[[1], [2], [3], [4], [5], [6], '\a']
Why is the [7]
shown as \a
? Is this because of the 7
(codepoint?) meaning some non-printable character?
If the result lists are not single-item this doesn’t happen (I suspect because no interpretation of the value as codepoint happens):
iex(34)> Enum.chunk_by([2, 4, 6, 1, 3, 5, 7], fn(x) -> rem(x, 2) == 0 end)
[[2, 4, 6], [1, 3, 5, 7]]
Thanks in advance!