Will doSomeCalculations be called if a is nil?
a.position = [self doSomeCalculations];
I guess it has to as doSomeCalculations can alter the state, but I’m not sure.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If
positionis a property and you rewrite the statement to the equivalent bracket syntax, you end up with:No lazy evaluation is performed here. It’s not any different from nested function calls when you consider that all these bracketed expressions are transformed into function calls to
objc_msgSend():The bottom line is,
[self doSomeCalulations]is evaluated even ifaisnil.