View Source Runbox.Utils.Map (runbox v13.0.3)

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

Link to this function

get_path(map, path, default \\ nil)

View Source
@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"