A.OrdMap.pop_lazy
You're seeing just the function
pop_lazy
, go back to A.OrdMap module for more information.
Specs
Lazily returns and removes the value associated with key
in ord_map
.
If key
is present in ord_map
, it returns {value, new_map}
where value
is the value of
the key and new_map
is the result of removing key
from ord_map
. If key
is not present in ord_map
, {fun_result, ord_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> ord_map = A.OrdMap.new(b: "Bat", a: "Ant", c: "Cat")
iex> expensive_fun = fn -> "Zebra" end
iex> {"Ant", updated} = A.OrdMap.pop_lazy(ord_map, :a, expensive_fun)
iex> updated
#A.OrdMap<%{b: "Bat", c: "Cat"}, sparse?: true>
iex> {"Zebra", not_updated} = A.OrdMap.pop_lazy(ord_map, :z, expensive_fun)
iex> not_updated
ord(%{b: "Bat", a: "Ant", c: "Cat"})