Keyword.update

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

update(keywords, key, default, fun)

View Source

Specs

update(
  t(),
  key(),
  default :: value(),
  (existing_value :: value() -> new_value :: value())
) :: t()

Updates the key in keywords with the given function.

If the key does not exist, it inserts the given default value.

If there are duplicated keys, they are all removed and only the first one is updated.

The default value will not be passed through the update function.

Examples

iex> Keyword.update([a: 1], :a, 13, fn existing_value -> existing_value * 2 end)
[a: 2]

iex> Keyword.update([a: 1, a: 2], :a, 13, fn existing_value -> existing_value * 2 end)
[a: 2]

iex> Keyword.update([a: 1], :b, 11, fn existing_value -> existing_value * 2 end)
[a: 1, b: 11]