There are two formats with essentially the same semantics.
-The unbraced expression if (C) then T else E
is equivalent to
- the braced expression if (C) { T } else { E }
.
The ternary expression C ?? T !! E
is equivalent to the
- braced expression if (C) { T } else { E }
.
The ternary operator syntax is borrowed from Perl6.
The value V of a conditional expression using the - braced format is obtained by applying the following rules in order, finishing - as soon as V has a value:
+The braced expression if (C) then {T}
is equivalent to the
+ unbraced expression if (C) then T else ()
.
The value V of a conditional expression in the form if (C) then T
+ else E
is obtained as follows:
Let C be the Let B be the
If C is true, V is the
- value of the
The
Let C' be the
If C' is true, V is the
- value of the
If there is an
If B is true, V is the + result of evaluating T.
V is the empty sequence.
+Otherwise, V is the + result of evaluating E.
Whichever format is used, the first step in processing a conditional expression is to find
-the
The value of a conditional expression is defined as follows: If the
-effective boolean value of the test expression is true
, the value of the then-expression is returned. If the
-effective boolean value of the test expression is false
,
-the value of the else-expression is returned.
Conditional expressions have a special rule for propagating The above expression can equivalently be written: The following example returns the attribute node The following example tests a number of conditions: In the unbraced format, both the In the braced format, an In the braced format, the expression terminates unambiguously with the closing
+ brace.@discount
provided the value of @price
@@ -20798,15 +20761,15 @@ else $part/retail]]>
then
and else
clauses
are mandatory.else
clause is always unambiguously
- associated with the immediately containing