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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to