The reason why Enum
always returns a list is because there are many Enumerable.t
types, which invalidate their own constraints when mapped, like ranges or various streamed enumerables. E.g. what would Enum.map(1..10, & &1 * 10)
return.
As alternative in elixir you have the Collectable
protocol as well as all the erlang/datatype specific functions like the already mentioned Map.new
.