Home Segments Index Top Previous Next

170: Mainline

The value of the following conditional-operator expression is the character string "point" if the price change is one point; otherwise, the value is the character string "points":

 Conditional    If-true      If-false 
 expression    expression   expression 
     |             |            | 
     v             v            v 
-----------     -------     -------- 
change == 1  ?  "point"  :  "points" 

You can, if you want, 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.