Runbox.Utils.Map (runbox v26.0.0)

View Source

A set of utility functions for Maps.

Summary

Functions

Follows the path in the (deep) map, defaulting to default if some of the objects on the path is missing.

Functions

get_path(map, path, default \\ nil)

@spec get_path(map(), [binary() | atom()], any()) :: any()

Follows the path in the (deep) map, defaulting to default if some of the objects on the path is missing.

Example

iex> object = %{"some" => %{"deep" => %{"object" => "data"}}}
...> Runbox.Utils.Map.get_path(object, ["some", "deep", "object"])
"data"
iex> Runbox.Utils.Map.get_path(object, ["non-existent"], "default")
"default"