It is intentional because pop_in does exactly what you want. It deletes and
returns the value deleted, which should be straight-forward to discard.


*José Valim*
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D

On Fri, Jul 15, 2016 at 10:16 PM, Myron Marston <[email protected]>
wrote:

> Currently, Elixir provides a number of functions that make working with
> nested data structures very easy and pleasant:
>
>    - get_in/2
>    - get_and_update_in/2 and get_and_update_in/3
>    - update_in/2 and update_in/3
>    - put_in/2 and put_in/3
>    - pop_in/1 and pop_in/2
>
> Unfortunately, there’s no similar function for deleting a value from a
> nested structure. Is its omission intentional? I think a delete_at
> function would be very useful:
>
> data = %{users: [%{name: "John", age: 27}, %{name: "Betty", age: 40}]}
> delete_at(data, [:users, Access.all(), :age])# => %{users: [%{name: "John"}, 
> %{name: "Betty"}]}
>
> I imagine it would also make sense to provide a delete_at/1 macro that
> allows the path to be passed using access syntax, just like what put_in/2,
> pop_in/1, etc provide.
>
> Thoughts?
>
> Myron
> ​
>
> --
> You received this message because you are subscribed to the Google Groups
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-core/1d4e99a5-1b9c-4bd6-8313-a55484639a87%40googlegroups.com
> <https://groups.google.com/d/msgid/elixir-lang-core/1d4e99a5-1b9c-4bd6-8313-a55484639a87%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4JUJMKaD3-zLi7_c-wgdFD-hh7LbvHK7y0cXv11Sjkw0w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to