2

I when I use the code:

Enum.to_list 9..12

The following gets returned instead of a list:

'\t\n\v\f'

It seems to only happen with these specific numbers. Is this a bug? Or am I missing something?

Chris Martin
  • 30,334
  • 10
  • 78
  • 137
Korbin
  • 1,788
  • 2
  • 18
  • 29

1 Answers1

2

I believe Binaries, strings and char lists in the getting-started documentation covers everything you need to understand what's going on here.

If all of the values in a list fall within the range of ASCII code points, then IEx will display the result as a character list. \t is ASCII value 9, \n is 10, and so on.

Here's another example:

iex> Enum.to_list 65..70
'ABCDEF'
Chris Martin
  • 30,334
  • 10
  • 78
  • 137
  • Ahh. That makes sense. I thought it was changing the datatypes in the list till I realized that I could access the values like any other numbers. – Korbin Jul 04 '16 at 05:36