ExAequoBase.Map (ExAequoBase v0.1.6)
View SourceMap helpers
Summary
Functions
put_if is putting values into a map only if a certain value exists
Types
@type atoms() :: [atom()]
@type binaries() :: [binary()]
@type error_t() :: {:error, binary()}
@type error_t(t) :: {:error, t}
@type maybe(t) :: nil | t
@type natural() :: non_neg_integer()
@type numbered(t) :: {t, number()}
@type numbered_lines_t() :: [numbered_line_t()]
@type ok_t() :: {:ok, any()}
@type ok_t(t) :: {:ok, t}
@type pair_t(t) :: {t, t}
@type pair_t(lt, rt) :: {lt, rt}
@type pairs_t() :: [pair_t()]
@type pairs_t(t) :: [pair_t(t)]
@type pairs_t(lt, rt) :: [pair_t(lt, rt)]
@type rgx_pair() :: {Regex.t(), ExAequoFn.NamedFn.t()}
@type rgx_pairs() :: [rgx_pair()]
@type zero_fn_t() :: (-> any())
@type zero_fn_t(t) :: (-> t)
Functions
put_if is putting values into a map only if a certain value exists
iex(1)> put_if(%{a: 1}, true, [a: 2, b: 3])
%{a: 2, b: 3}
keys can be of any type
iex(2)> put_if(%{}, true, [{"a", 42}])
%{"a" => 42}
But false values return an unchanged map
iex(3)> put_if(%{a: 1}, false, [a: 2, b: 3])
%{a: 1}