Water 5-Flow Control and Boolean-Sequential Flow
class return
Contract
Parameter keyDefault valueType
valuenull
fromnull
Water Contract
<class return
  value=null
  from =null
/>

See also: method, for_each, break

When a call to return is executed, the execution of the current sequence of instructions is stopped and the specified value is returned; if value is not specified, it defaults to null . In many programming languages, return is a required keyword used to indicate the return value of a method. In Water methods, the last result value of a sequence of instructions is the return value; the return value is said to be implicit .
Example: Implicit return value (last value)
<method foo> 543 555 </> 
<foo/>
555

a wob
Parameter keyDefault valueType
valuenull
An explicit call to return is usually not needed in Water. A call to return is only needed for those occasions when it is necessary to halt the current execution sequence somewhere before the end, and return a value immediately, skipping the remainging instructions.

a wob
value=null
Example: Explicit null return value (not last)
<method foo> <return /> 555 </> 
<foo/>
null
a wob
value=wob
Example: Explicit Water object return value (not last)
<method foo> <return 543 /> 555 </> 
<foo/>
543

a wob
Parameter keyDefault valueType
fromnull
The from argument specifies how far up the call stack to halt the execution of instructions.

a wob
from=null
If from is not specified, or if it is null, return returns from the current enclosing expression.
<method foo> <return 543 /> 555 </>
<foo />
543
a wob
from="method name"
If from is the name of a method, then it returns from the innermost method call of that name.
<method foo> <return 543 from="foo"/> 555 </> 
<foo/>
543
<method foo> <return 541 "baz" /> 559 </>
<method bar> <foo/>       669 </>
<method baz> <foo/>       779 </>
<baz/>
541
a wob
from="all"
If there is no method by that name on the stack, then all methods on the stack are returned from. A convenient way to return from all methods is to use a value for from of "all". In that case, the value returned will be the return object itself, which will have fields of value and from.
<method foo> <return 540 "all" /> 559 </>
<method bar> <foo/>       669 </>
<method baz> <bar/>       779 </>
<baz/>.value
540
a wob
from="for_each"
If return is used to return from a for_each loop, the value specified will be returned instead of the loop's current for_each_result.
10.<for_each >
   <if> value.<more 7 /> <return <thing color="red" /> from="for_each" /> </if>
   value
</for_each>
<thing color="red"/>