In MATLAB, if you type if (a)&&(b), then b isn’t tested if a is false. This is really handy for cases where the second condition would throw an error if the first condition isn’t true.
In Objective C, this doesn’t appear to be the case. So, my question is: are there any similar ways to have ordered conditions in an if statement? Or must the two statements simple be nested? (E.g., if (a){ if(b) {.)
Thanks for reading.
This is incorrect. C and its derivatives, including C++ and Objective-C, follow the same short-circuiting rules that you’re familiar with from Matlab. In an expression of the form:
ywill not be evaluated ifxis false.