-1

Enum.chunk_every([1, 2, 3, 4, 5, 6], 2)

Gives output [[1, 2], [3, 4], [5, 6]] on console.

But, Enum.chunk_every([1, 2, 3, 4, 5, 6, 7, 8], 2)

Gives [[1, 2], [3, 4], [5, 6], '\a\b']

Why does it return ascii characters for some integers?

Gopal B Shimpi
  • 129
  • 1
  • 6

1 Answers1

1

It's a not a matter of Enum.chunk_every/2, but rather the fact that characters that are "printable" in terms of ASCII table, are displayed as ASCII characters.

Check this answer.

To avoid that some people add 0 at the very end of very beginning of the list or you just ignore it - it case you need to check these integers you can:

a = [[1, 2], [3, 4], [5, 6], [7, 8]]
IO.inspect a, charlists: :as_lists  
PatNowak
  • 5,721
  • 1
  • 25
  • 31