Shiny Language Reference

Language Reference > Basic Language


return

return optional_expression;

 

Returns from a function to the caller

The RETURN statement is used to immediately exit a function and return the execution point to the instruction immediately after the function call. It is also used to return a value from a function to the calling code. If the RETURN statement is used in a "top level" event handler, execution of the handler ceases and control is returned to Brass. If the function has been declared with no return type it is optional to supply a RETURN statement.

 

Parameters

optional_expression

If the function containing the return statement has been declared with a return type, the RETURN statement must return a value that can reasonably be converted to the declared type. If the function has been declared with a VOID return type, or with no return type specified, it is not legal to supply an expression.

 

Return Value

Although a statement, it effectively provides a return value of the optional parameter.

 

Example Code

int function GenerateNumber()
{
    return 99;
}

function DoSomething()
{
    return;
}