Conditional Operators
by
, January 29th, 2012 at 04:52 PM (1412 Views)
Basically, I like to look at Conditional Operators as a quick way of implementing an If Statement. That's really all they are. Take a look at this code.
You can see that we've initalised an integer with the value of 50. Our Conditional Operator then checks to see if it's greater than thirty (age > 30 ?). We use a question mark to see if the condition is true. You then write the true and false outputs separated by a colon. That's really all there is to it!