diff options
author | Hassan Shaikley <hassan.shaikley@gmail.com> | 2019-08-03 02:43:30 -0700 |
---|---|---|
committer | Fernando Tapia Rico <fertapric@gmail.com> | 2019-08-03 11:43:30 +0200 |
commit | 7c31ce174a4cde40366b941332aa25f885995639 (patch) | |
tree | 18327f463113642b9d8935992dcd1a0cb668a442 | |
parent | b08593b9d1b82e65035abc9bf074ea47dc5817b1 (diff) | |
download | elixir-7c31ce174a4cde40366b941332aa25f885995639.tar.gz |
Add example for Access.get_and_update/3 (#9261)
-rw-r--r-- | lib/elixir/lib/access.ex | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/elixir/lib/access.ex b/lib/elixir/lib/access.ex index e654d5286..bb0d1da0e 100644 --- a/lib/elixir/lib/access.ex +++ b/lib/elixir/lib/access.ex @@ -329,6 +329,14 @@ defmodule Access do 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]} + """ @spec get_and_update(data, key, (value -> {get_value, value} | :pop)) :: {get_value, data} when get_value: var, data: container |