Keyword.put_new_lazy
You're seeing just the function
put_new_lazy
, go back to Keyword module for more information.
Specs
Evaluates fun
and puts the result under key
in keyword list unless key
is already present.
This is useful if the value is very expensive to calculate or generally difficult to setup and teardown again.
Examples
iex> keyword = [a: 1]
iex> fun = fn ->
...> # some expensive operation here
...> 3
...> end
iex> Keyword.put_new_lazy(keyword, :a, fun)
[a: 1]
iex> Keyword.put_new_lazy(keyword, :b, fun)
[b: 3, a: 1]