The presence of rarely used functions is not an argument for the addition 
of further rarely used functions.

On Wednesday, July 24, 2019 at 1:05:59 PM UTC-4, Mário Guimarães wrote:
>
> It seems this function was proposed here 
> https://github.com/elixir-lang/elixir/pull/5917
>
> and dropped because:
>
>
>    1. put_new and put_new! pair behaves differently from !-paired 
>    functions, I’m not sure if it’s good thing to break expectations in that 
>    case.
>    2. I don’t feel a huge need for put_new! - put_new itself is already 
>    rather rare use case, this one would be even rarer.
>    
> Regarding point 1) I can say that Map.replace!/update! also " behaves 
> differently from !-paired functions", yet they still exist
>
> Regarding point 2) well ... there many other functions many of us found 
> very infrequent or no use so far ¯\_(ツ)_/¯
>
> My opinion is that it can be useful to make the code more bulletproof, 
> much like Map.replace!/update! do.
>
> Mário
>
>
>
>
> quarta-feira, 24 de Julho de 2019 às 17:47:34 UTC+1, Mário Guimarães 
> escreveu:
>>
>> Hello,
>>
>> presently there is no function that throws an error in case we want to 
>> put a really new key in a map.
>>
>> The function Map.put_new only does nothing if the key is already there.
>>
>> The idea for Map.put_new! is to throw an error if the key is there. The 
>> use case is the developer who wants to be sure that the key is not there, 
>> as otherwise it means there is an error in the application code. As such, 
>> an exception should be raised.
>>
>> Is this a useful addition to Map?
>>
>> Thanks
>> Mário
>>
>

-- 
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 elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/0aa70608-1464-4c61-acb3-b38c1a6c4633%40googlegroups.com.

Reply via email to