View Source StepFlow.Map (StepFlow v1.8.0)

Extend Map with some additional functions.

Summary

Functions

Get a key matching on an atom or a string.

Replace an item in a map, with atom or string keys.

Functions

Link to this function

get_by_key_or_atom(dict, atom, default \\ nil)

View Source

Get a key matching on an atom or a string.

Default value can be specified.

Examples

iex> StepFlow.Map.get_by_key_or_atom(%{key: "value"}, :key)
"value"

iex> StepFlow.Map.get_by_key_or_atom(%{"key" => "value"}, :key)
"value"

iex> StepFlow.Map.get_by_key_or_atom(%{key: "value"}, "key")
"value"

iex> StepFlow.Map.get_by_key_or_atom(%{"key" => "value"}, "key")
"value"
Link to this function

replace_by_atom(dict, atom, value)

View Source

Replace an item in a map, with atom or string keys.

Examples

iex> StepFlow.Map.replace_by_atom(%{key: "value"}, :key, "replaced_value")
%{key: "replaced_value"}

iex> StepFlow.Map.replace_by_atom(%{"key" => "value"}, :key, "replaced_value")
%{key: "replaced_value"}

iex> StepFlow.Map.replace_by_atom(%{"key" => "value"}, "key", "replaced_value")
%{key: "replaced_value"}
Link to this function

replace_by_string(dict, string, value)

View Source