The conditional operator
? : uses the boolean value of one expression to decide which of two other expressions should be evaluated.
ConditionalExpression: ConditionalOrExpression ConditionalOrExpression
The conditional operator is syntactically right-associative (it groups right-to-left). Thus,
a?b:c?d:e?f:g means the same as
The conditional operator has three operand expressions.
? appears between the first and second expressions, and
: appears between the second and third expressions.
The first expression must be of type
Boolean, or a compile-time error occurs.
It is a compile-time error for either the second or the third operand expression ...