Access.get_and_update

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

get_and_update(data, key, function)

View Source

Specs

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

Invoked in order to access the value under key and update it at the same time.

The implementation of this callback should invoke fun with the value under key in the passed structure data, or with nil if key is not present in it. This function must return either {current_value, new_value} or :pop.

If the passed function returns {current_value, new_value}, the return value of this callback should be {current_value, new_data}, where:

  • current_value is the retrieved value (which can be operated on before being returned)

  • new_value is the new value to be stored under key

  • new_data is data after updating the value of key with new_value.

If the passed function returns :pop, the return value of this callback must be {value, new_data} where value is the value under key (or nil if not present) and new_data is data without key.

See the implementations of Map.get_and_update/3 or Keyword.get_and_update/3 for more examples.