A.OrdMap.get_lazy

You're seeing just the function get_lazy, go back to A.OrdMap module for more information.
Link to this function

get_lazy(ord_map, key, fun)

View Source

Specs

get_lazy(t(k, v), k, v) :: v | nil when k: key(), v: value()

Gets the value for a specific key in ord_map.

If key is present in ord_map then its value value is returned. Otherwise, fun is evaluated and its result is returned.

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(a: "Ant", b: "Bat", c: "Cat")
iex> expensive_fun = fn -> "Zebra" end
iex> A.OrdMap.get_lazy(ord_map, :a, expensive_fun)
"Ant"
iex> A.OrdMap.get_lazy(ord_map, :z, expensive_fun)
"Zebra"