#Weird behavior of Enum.slice

1 messages · Page 1 of 1 (latest)

languid locust
#

I run this piece of code

list = [1, 2, 3, 4, 5, 6, 7, 8, 9]
start_index = 5
result = Enum.slice(list, start_index..-1)
IO.inspect(result)

The output is [6, 7, 8, 9] as expected.
But once I change start_index to 6, the output becomes ~c"\a\b\t" instead of [7, 8, 9].
What is going on?

bronze surge
#

Charlist. It is the same data, just different representation. Just like for example <<42>> == "*" or 0xFF == 255 - ~c"\a\b\t" == [7, 8, 9]

#
languid locust
#

Oh, I see. Thank you very much!