Map.values returns '\f' when it shouldn't

Hi All!

I’ve met something easily reproductible and weird.
Bellow, you can see the versions of elixir and erlang I’m using as well as the lines I executed on iex:

Erlang/OTP 24 [erts-12.1.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Interactive Elixir (1.13.0-rc.0) - press Ctrl+C to exit (type h() ENTER for help)

iex(1)> Map.values(%{a: 1})


iex(2)> Map.values(%{a: 12})


I was expecting this return value [12].

Please tell me if you encounter the same results, if you know the reason behind this?
I suspect a bug but I’m just hoping for some anomaly in my thinking or setup :slightly_smiling_face:

Thanks! :smiley:

This is normal. See Binaries, strings, and charlists - The Elixir programming language for an explanation. Tl;Dr is that in erlang strings are lists of numbers, and elixir has a syntax for that as well to promote compatibility with Erlang.

Edit: also want to point out, you do have a list of numbers there, it’s just printed differently. Eg
'\f' == [12]


Thanks a lot! So it was an anomaly in my thinking :laughing:

1 Like