How to create a map from a list of two item tuples in Elixir
The simplest way to do this is:
Enum.into(list, %{})
Map
module also supports such lists as a parameter to the new
function:
iex> Map.new([{1, 2}, {3, 4}])
%{1 => 2, 3 => 4}
The simplest way to do this is:
Enum.into(list, %{})
Map
module also supports such lists as a parameter to the new
function:
iex> Map.new([{1, 2}, {3, 4}])
%{1 => 2, 3 => 4}