Skip to content

Commit

Permalink
Fix doctest unused variable warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Qqwy committed Sep 6, 2021
1 parent 7192e25 commit 5f6fbb5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/arrays.ex
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,19 @@ contents = quote do
##{@current_default_array}<[1, 2, 33, 4]>
iex> arr = update_in(arr[1], (&(&1 * -2)))
##{@current_default_array}<[1, -4, 33, 4]>
iex> arr = update_in(arr[-1], (&(&1 + 1)))
iex> update_in(arr[-1], (&(&1 + 1)))
##{@current_default_array}<[1, -4, 33, 5]>
Popping from a random location however, is not.
Only removals of the last element of the array are fast.
For this, use `Arrays.extract/1`.
iex> arr = Arrays.new([1, -4, 33, 5])
iex> {33, arr} = pop_in(arr[-2])
iex> {33, _arr} = pop_in(arr[-2])
** (ArgumentError) There is no efficient implementation possible to remove an element from a random location in an array, so `Access.pop/2` (and returning `:pop` from `Access.get_and_update/3` ) are not supported by #{@current_default_array}. If you want to remove the last element, use `Arrays.extract/1`.
iex> arr2 = Arrays.new([10, 20, 30])
iex> {20, arr2} = get_and_update_in(arr2[1], fn _ -> :pop end)
iex> {20, _arr2} = get_and_update_in(arr2[1], fn _ -> :pop end)
** (ArgumentError) There is no efficient implementation possible to remove an element from a random location in an array, so `Access.pop/2` (and returning `:pop` from `Access.get_and_update/3` ) are not supported by #{@current_default_array}. If you want to remove the last element, use `Arrays.extract/1`.
iex> arr2 = Arrays.new([10, 20, 30])
Expand Down

0 comments on commit 5f6fbb5

Please sign in to comment.