File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -435,6 +435,13 @@ defmodule Access do
435
435
...> prev -> {prev, String.upcase(prev)}
436
436
...> end)
437
437
{"john", [%{name: "JOHN"}, %{name: "mary"}]}
438
+
439
+ `at/1` can also be used to pop elements out of a list or
440
+ a key inside of a list:
441
+
442
+ iex> list = [%{name: "john"}, %{name: "mary"}]
443
+ iex> pop_in(list, [Access.at(0)])
444
+ {%{name: "john"}, [%{name: "mary"}]}
438
445
iex> pop_in(list, [Access.at(0), :name])
439
446
{"john", [%{}, %{name: "mary"}]}
440
447
@@ -477,7 +484,7 @@ defmodule Access do
477
484
defp get_and_update_at ( [ head | rest ] , 0 , next , updates ) do
478
485
case next . ( head ) do
479
486
{ get , update } -> { get , :lists . reverse ( [ update | updates ] , rest ) }
480
- :pop -> { head , :lists . reverse ( [ head | updates ] , rest ) }
487
+ :pop -> { head , :lists . reverse ( updates , rest ) }
481
488
end
482
489
end
483
490
You can’t perform that action at this time.
0 commit comments