antikythera v0.4.0 Antikythera.MapUtil View Source

Utility functions to work with maps.

Link to this section Summary

Functions

Update the key in map with the given function, only when the key exists. Unlike Map.update!/3, it returns :error if the key does not exist.

Link to this section Functions

Specs

difference(%{required(k) => v}, %{required(k) => v}) ::
  {%{required(k) => v}, %{required(k) => {v, v}}, %{required(k) => v}}
when k: any(), v: any()

Specs

map_values(%{required(k) => v1}, ({k, v1} -> v2)) :: %{required(k) => v2}
when k: any(), v1: any(), v2: any()
Link to this function

update_existing(map, key, fun)

View Source

Specs

update_existing(map(), any(), (any() -> any())) :: {:ok, map()} | :error

Update the key in map with the given function, only when the key exists. Unlike Map.update!/3, it returns :error if the key does not exist.