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/2b7faae6-a730-4cb2-bccd-cb2637f351ac%40googlegroups.com.