Conditional structures: Difference between revisions

Content deleted Content added
m →‎{{header|ooRexx}}: fix description of the short circuited conditional.
Walterpachl (talk | contribs)
m →‎{{header|ooRexx}}: remove blank lines
Line 2,473: Line 2,473:
may also be a list of conditional expressions separated by commas. The expressions are evaluated left-to-right, and evaluation
may also be a list of conditional expressions separated by commas. The expressions are evaluated left-to-right, and evaluation
will stop with the first '0' result. For example,
will stop with the first '0' result. For example,
<lang ooRexx>if arg~isa(.string) & arg~left(1) == "*" then call processArg arg</lang>
<lang ooRexx>
if arg~isa(.string) & arg~left(1) == "*" then call processArg arg
</lang>


would fail with a syntax error if the variable arg does not hold a string because the right-hand-side of the expression
would fail with a syntax error if the variable arg does not hold a string because the right-hand-side of the expression
is still evaluated. This can be coded as
is still evaluated. This can be coded as


<lang ooRexx>if arg~isa(.string), arg~left(1) == "*" then call processArg arg</lang>
<lang ooRexx>
if arg~isa(.string), arg~left(1) == "*" then call processArg arg
</lang>
With this form, the second conditional expression is only evaluated if the first expression is true.
With this form, the second conditional expression is only evaluated if the first expression is true.