Kernel.pop_in
You're seeing just the function
pop_in
, go back to Kernel module for more information.
Specs
pop_in(data, [Access.get_and_update_fun(term(), data) | term(), ...]) :: {term(), data} when data: Access.container()
Pops a key from the given nested structure.
Uses the Access
protocol to traverse the structures
according to the given keys
, unless the key
is a
function. If the key is a function, it will be invoked
as specified in get_and_update_in/3
.
Examples
iex> users = %{"john" => %{age: 27}, "meg" => %{age: 23}}
iex> pop_in(users, ["john", :age])
{27, %{"john" => %{}, "meg" => %{age: 23}}}
In case any entry returns nil
, its key will be removed
and the deletion will be considered a success.
iex> users = %{"john" => %{age: 27}, "meg" => %{age: 23}}
iex> pop_in(users, ["jane", :age])
{nil, %{"john" => %{age: 27}, "meg" => %{age: 23}}}