Hacker News new | ask | show | jobs
by _sdegutis 3000 days ago
Objective-C also allows nil to receive messages which then just returns nil also. I’ve always found this really natural in that you can assume something is either valid or null and avoid a whole lot of null checks this way. That said, I’ve never been terribly frustrated by other languages either which throw when calling methods on null. Maybe it’s because of heavy use of certain design patterns that make it so it’s never really a surprise?
1 comments

It also means a chained call with an nil in it still complete from start to end. So it has additional overhead, and you better not have side effects in there.

All in all, I'd like to have some kind of "?" operator in Python, I do think the pros are most of the time greater than the cons.