Map.pop
You're seeing just the function
pop
, go back to Map module for more information.
Specs
pop(map(), key(), default) :: {value(), updated_map :: map()} | {default, map()} when default: value()
Removes the value associated with key
in map
and returns the value and the updated map.
If key
is present in map
, it returns {value, updated_map}
where value
is the value of
the key and updated_map
is the result of removing key
from map
. If key
is not present in map
, {default, map}
is returned.
Examples
iex> Map.pop(%{a: 1}, :a)
{1, %{}}
iex> Map.pop(%{a: 1}, :b)
{nil, %{a: 1}}
iex> Map.pop(%{a: 1}, :b, 3)
{3, %{a: 1}}