Re: syntax question: question marks
Re: syntax question: question marks
- Subject: Re: syntax question: question marks
- From: Jens Bjerrehuus <email@hidden>
- Date: Sat, 30 Aug 2003 10:25:04 +0200
Just a little nit-picking. :)
mandag 25. aug 2003 kl. 05:48 skrev Wade Tregaskis:
This is a basic C language construct, which is essentially a shorthand
if..else statement. The statement immediately preceding the question
mark is evaluated - if it is true, the statement on the left of the
colon is evaluated, otherwise the statement on the right is. e.g.
The ?: operator is not a statement, but an expression. And more
importantly, the parts of the ?: expression are themselves expressions.
It's defined like this in K&R second edition:
conditional-expression:
logical-OR-expression
logical-OR-expression ? expression : conditional-expression
This means that you cannot use statements after either the ? or the :.
This makes it different from the if statement where it is possible to
nest statements after the if or the else keywords. It is e.g. not
possible to use an if statement after the ? or the :.
Apart from that I agree with Wade on the typical usage patterns of this
expression.
Kind regards
Jens
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.