News for hackers. Stuff that matters.
Re:You’re better off using Exceptions by takeda on Monday February 03, 2020 @11:56AM (#22226047)
It all depends on context. I believe that's why python for example throws an exception if given key doesn't exist when you use `dictionary[key]` but also gives you option to call `dictionary.get(key, [value])` which returns `None` or `value` (if specified) if the `key` doesn't exist.
Re:You’re better off using Exceptions by samatman on Monday February 03, 2020 @12:59PM (#22226898)
That one bites me when I've been away from Python for awhile. I prefer 'open' maps/dicts, where every key is valid and any unassigned value is None/nil.

I don't consider looking for an invalid key exceptional, basically, so I wish the syntaxes were reversed, so I could use the more succinct form for (my) more common case.

Re:You’re better off using Exceptions by loopz on Monday February 03, 2020 @04:19PM (#22229226)
Golang maps returns the value type's zero value in case the key doesn't exist: https://blog.golang.org/go-maps-in-action

The idiomatic way here being that the zero value should be a sane default for that value. You are then free to create your own types ontop of that, but the defaults are often in the ballpark of where you want to be unless you have specific needs in your context.