According to the snippet below.
iex(24)> for c <- cols, r <- rows, into: %{}, do: {c, r}
%{1 => 10, 2 => 10, 3 => 10, 4 => 10, 5 => 10, 6 => 10, 7 => 10, 8 => 10,
9 => 10, 10 => 10}
The into: option should call this &Enum.into/2
def into(enumerable, %{} = collectable) when is_list(enumerable) do
Map.merge(collectable, :maps.from_list(enumerable))
end
which called the Erlang maps module function from_list(List)
from_list(List) -> Map
Takes a list of key-value tuples elements and builds a map.
The associations can be in any order, and both keys and values in the association can be of any term.
If the same key appears more than once, the latter (right-most) value is used and the previous values are ignored.
Is that right?
How’s :maps.from_list(List) getting rid of the duplicate keys?
It first transforms the list into a “no_duplicate_keys” list and then apply a recursive function to create the map, or the get_rid_of_duplicate_keys transformation is part of the recursive function and the raw list is passed to it?
BTW, Elixir doc is awesome!