Enum.flat_map beginners question

Hello, why does it do this?

iex(2)> Enum.flat_map [5,6,7,8,9], &([[&1],[&1]])
[[5], [5], [6], [6], ~c"\a", ~c"\a", ~c"\b", ~c"\b", ~c"\t", ~c"\t"]
iex(3)>

Hi @p.t.peter !

This is a common gotcha due to how charlists are represented, you can check this thread for more details explanations and a way to configure your shell to avoid it.

3 Likes