Syntax![]() A type reference has the following syntax: ![]() UseA method can only refer to packages, classes, and methods that you declared before, so they cannot be declared in whatever order. This is also the case for a recursive method because the return type of a method is only known after it is declared and compiled. Therefore, you must predeclare the methods to enable recursion.
A method can require parameters. Any valid code can be passed as a parameter to a
method.
Example 1METHOD MyClass.setQuantity(quantity : Integer) : { THIS.quantity := quantity };
Example 2// Pre-declaration with type of result
METHOD MyClass.fibonacci(n : Integer) : VOID(Integer);
// Sub-optimal implementation with 2 recursion branches created every time
METHOD MyClass.fibonacci(n : Integer) : {
n >= 2
IF TRUE: (fibonacci(n - 1) + fibonacci(n - 2))
ELSE: 1
};
| |||||||||||