Reading the documentation for Enum.into/2,
gave me the wrong idea of what the function does.
http://elixir-lang.org/docs/master/elixir/Enum.html#into/2
The summary reads:
into(collection, list): Inserts the given enumerable into a
collectable.
which made me thing that list(the enumerable) will be inserted into
collection (the collectable)
the first example made sense:
iex> Enum.into([1, 2], [0])
[0, 1, 2]
but the second one didn't
iex> Enum.into([a: 1, b: 2], %{})
%{a: 1, b: 2}
Why inserting an empty map into a list, will convert the list into a
map.
When I read the specs, I understand there was something wrong.
Specs:
into(Enumerable.t, Collectable.t) :: Collectable.t
Alright, that's easy to fix. But then going reviewing the documentation
for the module I see the subject of the functions named "collection" is
always used to refer to an Enumerable, which is what the Enum module is about.
So i propose to rename the "Enum" mode to be called "Collect"!
nah.. just a bad joke ;-)
so.. what I think we need to do is rename the "collection" arguments to
"enumerable", and every reference to them.
and use collection only for collectables, such as in the Enum.into case.
WDYGT?