Map.put_new_lazy

You're seeing just the function put_new_lazy, go back to Map module for more information.
Link to this function

put_new_lazy(map, key, fun)

View Source

Specs

put_new_lazy(map(), key(), (() -> value())) :: map()

Evaluates fun and puts the result under key in map unless key is already present.

This function is useful in case you want to compute the value to put under key only if key is not already present, as for example, when the value is expensive to calculate or generally difficult to setup and teardown again.

Examples

iex> map = %{a: 1}
iex> fun = fn ->
...>   # some expensive operation here
...>   3
...> end
iex> Map.put_new_lazy(map, :a, fun)
%{a: 1}
iex> Map.put_new_lazy(map, :b, fun)
%{a: 1, b: 3}