Map.pop_lazy
You're seeing just the function
pop_lazy
, go back to Map module for more information.
Specs
Lazily returns and removes the value associated with key
in map
.
If key
is present in map
, it returns {value, new_map}
where value
is the value of
the key and new_map
is the result of removing key
from map
. If key
is not present in map
, {fun_result, map}
is returned, where fun_result
is the result of applying fun
.
This is useful if the default value is very expensive to calculate or generally difficult to setup and teardown again.
Examples
iex> map = %{a: 1}
iex> fun = fn ->
...> # some expensive operation here
...> 13
...> end
iex> Map.pop_lazy(map, :a, fun)
{1, %{}}
iex> Map.pop_lazy(map, :b, fun)
{13, %{a: 1}}