Skip to content

Map

drop(map, keys)

Returns a map where keys are removed (dropped).

Examples:

$> drop(%{"a" => 1}, ["a"])
%{}
$> drop(%{"a" => 1, "b" => 2}, ["a"])
%{"b" => 2}

merge(m1, m2)

Merges two maps where map2 is overlaid on map1 meaning if key is nil we keep map1 value.

Examples:

$> merge(%{"a" => 1}, %{"a" => 2})
%{"a" => 2}
$> merge(%{"a" => 1}, %{"a" => nil})
%{"a" => 1}

take(map, keys)

Returns a map where only the given keys are kept.

Examples:

$> take(%{"a" => 1}, [])
%{}
$> take(%{"a" => 1, "b" => 2}, ["a"])
%{"a" => 1}