Water 5-Flow Control and Boolean-Branching
method if
Contract
Return typewob
No input parameters.
Parameter kindDefault valueType
Other unkeyed argumentsopt with ekind of expressionwob
Water Contract
<method if
  _other_unkeyed=opt=wob=ekind.expression="_body"/>

See also: do

A call to if provides a mechanism for choosing from among a list of actions based on given criteria. An if block contains pairs of expressions. The first item of a pair is the "condition", the second is the "action". if executes conditions in order. The first condition that returns a value other than false has its corresponding action executed and the value of that action is returned from the call to if . Subsequent clauses will be ignored. If no conditions return a non-false result, then null is returned from the call to if . A condition that is literally true if reached, will always cause its action to be executed. The symbol else is a synonym for true .
<set x=52>
 <if> x.<less 10/> 
       "got a 1 digit number"
      x.<more 99/> 
       "got a big number"
     else 
       "got a 2 digit number"
 </if>
</set>
"got a 2 digit number"
If a multiple-expression action is required, make the multiple expressions the content of a <do /> block expression. (Remember that the call to <do /> returns the result of the last expression in the call.)
<set x=150>
<if> x.<less 10 />
      "got a 1 digit number"
     x.<more 99 />
      <do <set x=x.<plus 10 /> /> x />
     else
      "got a 2 digit number"
</if>
</set>
160