PassiveSupport.Enum.to_map
You're seeing just the function
to_map
, go back to PassiveSupport.Enum module for more information.
Link to this function
to_map(enum)
Specs
to_map(Enumerable.t()) :: Map.t()
Converts an enumerable to a Map
, using the index of
each item as the item's key.
Examples
iex> to_map(["hello", "world", "how", "are", "you"])
%{0 => "hello", 1 => "world", 2 => "how", 3 => "are", 4 => "you"}
iex> to_map(["Elixir", "is", "cool"])
%{0 => "Elixir", 1 => "is", 2 => "cool"}
Link to this function
to_map(enum, key_function)
Specs
to_map(Enumerable.t(), function()) :: Map.t()
Not to be confused with Enum.map/2, returns a Map
with the key for each
item derived by the return of key_function(item)
or key_function(item, index)
Examples
iex> to_map(["Elixir", "is", "cool"], &String.reverse/1)
%{"si" => "is", "looc" => "cool", "rixilE" => "Elixir"}
iex> to_map(["hello", "world", "how", "are", "you"], fn (_, index) -> index end)
%{0 => "hello", 1 => "world", 2 => "how", 3 => "are", 4 => "you"}