4 ms·
Reminds me of Objective C happily calling a nil ptr, Apple wants to be generous and not pester you by terminating your app :-)
by DrTung 11y ago
Reminds me of Objective C happily calling a nil ptr, Apple wants to be generous and not pester you by terminating your app :-)
- mikeash 11y agoThat's not really the same. Messaging nil is not necessarily an error. Making it an error is just an arbitrary language choice. Messaging nil in Objective-C isn't an uncaught error, but an explicitly allowed action with fully defined results. One could certainly argue that making nil messaging an error is better, but either way it's a different sort of reasoning.
- melling 11y agoApple didn't invent Objective C. It has been this way since 1983, before Steve Jobs left Apple the first time: https://en.m.wikipedia.org/wiki/Objective-C https://en.m.wikipedia.org/wiki/Objective-C
- mdw 11y agoSwift will happily message nil also, for example: delegate?.someOptionalMessage?(param: param) It's a great language feature I appreciated in Obj-C, and not lost to Swift!