The rest of the module makes use of the condition expression quite a bit. This is a good time to refresh your knowledge of the conditional expression.
x = c ? v1 : v2 is the same as the following code:
The conditional expression is right associative. This means that the implicit parantheses groups from right to left. Let us consider the following chained conditional expressions.
c1 ? t1 : c2 ? t2 : c3 ? t3 : f3
|
It is the same as the following:
c1 ? t1 : (c2 ? t2 : (c3 ? t3 : f3))
|
This means the expression
x = c1 ? t1 : c2 ? t2 : c3 ? t3 : f3
|
has the same meaning as the following code:
The above code is also commonly written as follows to save space.