3 ms·
That's not true across many of the languages I use, dict.pop returns a key error in python for instance. By having a version that raises the standard library i
by Grimm1 5y ago
That's not true across many of the languages I use, dict.pop returns a key error in python for instance.
By having a version that raises the standard library is basically saying not having a key is the error state.
- jolux 5y ago> That's not true across many of the languages I use, dict.pop returns a key error in python for instance. Yeah, sorry. I should have been more clear. This behavior is common in Lisps, which is what I’m used to. It’s less common in mainstream languages. With Elixir it may be Clojure-inspired. > By having a version that raises the standard library is basically saying not having a key is the error state. Not necessarily, it’s saying you can choose whether it should be an error or not. Notably other functions that error don’t give you the option of specifying a default. That’s the difference here. Nil is returned because it’s passed in, it’s the default argument for the “default value” parameter.