Wiki
Version 1 (modified by hopscc, 15 years ago)

--

Return Statement

The return statement terminates execution of the method in which it appears and returns control to the calling method.

The value of the expression clause is returned to the calling function converted to the type specified in the method declaration.
Constructors and destructors, and functions of type void, cannot specify an expression in the return statement.
Functions of all other types must specify an expression in the return statement

If the return statement is inside a try block, the finally block, if one exists, will be executed before control returns to the calling method.

Grammar

return [EXPRESSION]

Example

#Use an expression with a return statement to obtain the largest of two integers.
def max(a as int, b as int) as int is shared
    return if(a > b, a, b)

def main is shared
    nOne = 5
    nTwo = 7

    print String.format( '{0} is bigger', .max( nOne, nTwo ) )