Hi!
I am new in Elixir. Still learning syntax. But I I see very weird behavior while I am testing functions.
The question is about Enum.chunk_by
function.
list=[1,2,3,4,5,6,7,8,9,10]
Enum.chunk_by(list, & rem(&1,4)==0)
expected result is,
[[1,2,3],[4],[5,6,7],[8],[9,10]]
but, what I am receiving is
[[1, 2, 3], [4], [5, 6, 7], ~c"\b", ~c"\t\n"]
My elixir version is 1.17.3, on MacOS 15.1.1, M1 Pro
I am curious if there is some system-relative background of this result.
Thank you!
===
Answer for this question:
turned out ~c"\b" is equivalent to [8], and ~c"\t\n" is equivalent to [9,10]
as the chosen answer explains. This looks like a common mistake that a beginner is confused (like me). Thanks for all the answers! I couldn’t understand the short answers, but after I understand what is happening, even the short answers makes sense.