Delete a key?
thojanssens opened this issue · 4 comments
Is it possible to add a function to delete a key?
p = path "hey" / "you"
%{"hey" => %{"x" => 2}} == delete %{"hey" => %{"you" => 1, "x" => 2}}, p
p = path "hey" / 1
%{"hey" => [0, 2]} == delete %{"hey" => [0, 1, 2]}, p
Hi @thojanssens, yes it is possible, I already have a tested version with full support of key deletion. But I can't publish it yet, because I am currently working under very strict NDA, which affects even my off-time work. I will publish this new version as soon as my contract ends
Until then you can use something like
p = path "city" / "street"
Pathex.over(%{"city" => %{"street" => %{"house" => 1}}}, p, & Map.delete(&1, "house"))
Amazing! I'll wait 🙌
Thank you for offering me an alternative temporary solution in the meanwhile, it's much appreciated.
Thank you for sharing this library! I love to use it for making tests with changesets. I change the attrs input with pathex
for generating different data sets to test, based on a general large attrs map with lots of nested data.
One small suggestion: in the readme it would be nice to see how some operations are done without pathex
to see the difference (pathex
VS standard functions), i.e. see how much code is saved using the lib, and also for learning purposes, i.e. how it'd be done without the lib.
Thank you!
One small suggestion: in the readme it would be nice to see how some operations are done without pathex to see the difference (pathex VS standard functions), i.e. see how much code is saved using the lib, and also for learning purposes, i.e. how it'd be done without the lib.
Good point, I will think about it
Fixed in 2.0