A.Vector.get_and_update

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

get_and_update(vector, index, fun)

View Source

Specs

get_and_update(t(v), index(), (v -> {returned, v} | :pop)) :: {returned, t(v)}
when v: value(), returned: term()

Gets the value from key and updates it, all in one pass.

See Access.get_and_update/3 for more details.

Examples

iex> vector = A.Vector.new(1..8)
iex> {6, updated} = A.Vector.get_and_update(vector, 5, fn current_value ->
...>   {current_value, current_value && current_value * 100}
...> end); updated
vec([1, 2, 3, 4, 5, 600, 7, 8])
iex> {nil, updated} = A.Vector.get_and_update(vector, 8, fn current_value ->
...>   {current_value, current_value && current_value * 100}
...> end); updated
vec([1, 2, 3, 4, 5, 6, 7, 8])
iex> {4, updated} = A.Vector.get_and_update(vector, 3, fn _ -> :pop end); updated
vec([1, 2, 3, 5, 6, 7, 8])
iex> {nil, updated} = A.Vector.get_and_update(vector, 8, fn _ -> :pop end); updated
vec([1, 2, 3, 4, 5, 6, 7, 8])