Kernel.put_in
You're seeing just the function
put_in
, go back to Kernel module for more information.
Specs
Puts a value in a nested structure.
Uses the Access
module 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> put_in(users, ["john", :age], 28)
%{"john" => %{age: 28}, "meg" => %{age: 23}}
In case any of the entries in the middle returns nil
,
an error will be raised when trying to access it next.