Map.new

You're seeing just the function new, go back to Map module for more information.

Specs

new() :: map()

Returns a new empty map.

Examples

iex> Map.new()
%{}

Specs

new(Enumerable.t()) :: map()

Creates a map from an enumerable.

Duplicated keys are removed; the latest one prevails.

Examples

iex> Map.new([{:b, 1}, {:a, 2}])
%{a: 2, b: 1}
iex> Map.new(a: 1, a: 2, a: 3)
%{a: 3}
Link to this function

new(enumerable, transform)

View Source

Specs

new(Enumerable.t(), (term() -> {key(), value()})) :: map()

Creates a map from an enumerable via the given transformation function.

Duplicated keys are removed; the latest one prevails.

Examples

iex> Map.new([:a, :b], fn x -> {x, x} end)
%{a: :a, b: :b}