Reputation: 123
What is the use of this ( besides the non crash part ) ? I want to know in terms of thinking process behind such design.
Upvotes: 4
Views: 437
Reputation: 9857
Coming from a Java background, one of the thing I found hard to "make mine", was the total absence of the famous java.lang.NullPointerException
related to method invocation.
Once you get into it, you will find it is a total different approach and not a bad one also: you send a message, and if someone is not responding the program is not crashing.
This lead to enforce (in my opinion of course) to think about returning value, rather than to worry about something existing.
Upvotes: 2
Reputation: 40211
It's a design choice. And in Objective-C terminology, one "sends messages" to objects, instead of "calling methods". So you could say sending a message to an object that doesn't exist has simply no effect. If you address a real letter to a person that doesn't exist, no one will receive it, no one will respond or do anything.
Upvotes: 5