I guess, rereading your original proposal, you don't actually need the 
helper I just described, sorry.

On Thursday, July 23, 2020 at 9:26:59 AM UTC-4 Zachary Daniel wrote:

> I would use this function pretty often if it existed :)
>
> I'm not really a fan the `update_if` that Jose proposed because my biggest 
> use case has been "update a key, but I don't want to put a default in if it 
> doesn't exist". I think something like
>
> `Map.update_existing(map, :key, fn value -> value * 2 end)`
>
> You can also simulate the "update if" by putting a conditional in the 
> function like `if value != nil, ...`
> On Thursday, July 23, 2020 at 9:20:35 AM UTC-4 Riccardo Binetti wrote:
>
>> Hi everybody,
>> I would like to bring this proposal back since I just typed `def put_if` 
>> again in another module :)
>>  
>> Being my first proposal I don't know what is the usual process, but I 
>> think the discussion showed that there is some interest in this 
>> functionality.
>>  
>> I personally like the `update_if` proposal made by José because it's a 
>> more general construct that can be useful in various situation. I wouldn't 
>> mind also having a `Map.put_if` function in the Map module but I'm fine 
>> using `update_if` in case.
>> --
>> Riccardo
>>
>

-- 
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/3949c06f-406c-4849-ae80-f2bb39076e81n%40googlegroups.com.

Reply via email to