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

2024-12-10 Thread Juan Manuel Azambuja
Hi José! Thanks for getting back to me so quickly! I understand that adding all `*_if` functions wouldn't be so nice on the API. Regarding `then_if`, I think it solves the problem and can be applied to other situations, so I feel it's a better enhancement! Would you be interested in adding it

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

2024-12-10 Thread Andrew Timberlake
apply_if/3 ? On December 6, 2024, Ben Wilson wrote: Exploring what that looks concretely in this case: ``` map |> other_stuff |> then_if(opts[:foo], &Map.put(&1, :key, value)) ``` I like it! Conditional map insert helper functions are definitely something we've written over and over again in