Home Segments Index Top Previous Next

287: Mainline

The value of the following conditional-operator expression is the character string "degree" if the temperature change is 1 degree; otherwise, the value is the character string "degrees":

 Conditional   If-true     If-false 
 expression   expression  expression 
     |           |           | 
     v           v           v 
-----------   --------   --------- 
change == 1 ? "degree" : "degrees" 

You can, if you wish, employ parentheses to delineate the Boolean expression, but parentheses are not needed in the example, because the equality operator has precedence higher than that of the conditional operator, as shown in the hardcopy version of this book.