Quote:
|
Ternary Operators are used to give variable a value, It returns a certain value, You can't really use it to execute, For example functions.
|
What!? In what language is this? For Java and Perl this is perfectly valid.
Code:
x != null ? do(x) : doh() ;
sure this is invalid if doh() is a void method
Code:
printf( "%s\n", x != null ? do( x ) : doh() );
This wouldnt work, since printf needs a string to print, and doh() isnt going to return one. But yes, you can execute methods out of a ternary operator, you can even nest them!
Code:
return( ( gotAccount == YES ? ( status == 'A' ? YES : ( [self isSuspended] == YES ? YES : NO ) ) : NO ) );
jeffro