Access.get_and_update

You're seeing just the function get_and_update, go back to Access module for more information.
Link to this function

get_and_update(container, key, fun)

View Source

Specs

get_and_update(
  data,
  key(),
  (value() | nil -> {current_value, new_value :: value()} | :pop)
) :: {current_value, new_data :: data}
when data: container(), current_value: var

Gets and updates the given key in a container (a map, a keyword list, a struct that implements the Access behaviour).

The fun argument receives the value of key (or nil if key is not present in container) and must return a two-element tuple {current_value, new_value}: the "get" value current_value (the retrieved value, which can be operated on before being returned) and the new value to be stored under key (new_value). fun may also return :pop, which means the current value should be removed from the container and returned.

The returned value is a two-element tuple with the "get" value returned by fun and a new container with the updated value under key.

Examples

iex> Access.get_and_update([a: 1], :a, fn current_value ->
...>   {current_value, current_value + 1}
...> end)
{1, [a: 2]}