Functions
A function defines a mapping from an input value to an output value.
// Increment a value using the built-in increment operator +.
func a(b:@) -> @ {
+(b)
};
a(23)Syntactically, a function requires the following elements:
funckeywordFunction name (all lower case)
In parentheses, one or more arguments
->mapping operatorOutput type
In braces, code block of body
Terminating
;
Methods in class definitions are similar to functions, but must occur inside a class code block and do not have a prefatory func keyword.
Reentrancy/Recursion
Functions currently refer to themselves not by name but by the standard placeholder $. Thus, a Fibonacci function could look like this in Jock:
Last updated