View Source Antikythera.MapUtil (antikythera v0.5.1)

Utility functions to work with maps.

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.

Functions

@spec difference(%{required(k) => v}, %{required(k) => v}) ::
  {%{required(k) => v}, %{required(k) => {v, v}}, %{required(k) => v}}
when k: any(), v: any()
@spec 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
@spec 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.