![]() |
|
Navigation |
Synopsis Return a value as result of a Function.
Syntax
Description A return statement comes in two variants: without and with an expression,
both variants end the execution of the current function.
The first variant applies to functions with
void as return type.
The second variants applies to non-void functions and returns the value of Exp as result of the function invocation.
The following rules apply:
Examples
rascal>int twice(int n) { return 2 * n; } int (int): int twice(int); rascal>twice(5); int: 10Functions that only return a value can be abbreviated (and the return is implicit): rascal>int twiceb(int n) = 2 * n; int (int): int twiceb(int); rascal>twiceb(5); int: 10 ![]() |