Re: [elixir-core:11931] Proposal: Map.put_if/4

2024-12-06 Thread José Valim
Hi Juan! My initial gut feeling is that this approach does not scale. What if you want to delete a key conditionally? Should we have delete_if? It feels a more general approach would be to introduce `then_if`: then_if(subject, condition?, function) Or similar. :) *José Valimhttps://dashbit.co/

[elixir-core:11931] Proposal: Map.put_if/4

2024-12-06 Thread Juan Manuel Azambuja
Hello, After working with Elixir for some time I have found myself repeating some patterns when dealing with maps. One pattern I see repeated constantly in different apps developed by myself or others is adding values to a map conditionally or returning the map unchanged. This comes in differe