Function calls

Functions are blocks of code that may be invoked by issuing a function call. When a function call is performed, the code within the function is executed. When the function has finished doing its job, control is returned to the statement following the function call.

There are several built-in functions to call. Additionally, one may define new functions.

Some functions return a value that may be used as part of an expression. Other functions do not return any value. Returned values may nevertheless be ignored.

Functions may take zero or more arguments on which they operate. The arguments passed to a function must have the correct data types as expected by the invoked function.

All data types except arrays are passed by value to the called function. This means that the function cannot change the value of its arguments. Arrays, however, are passed by reference, so any changes done to array elements will be visible to the caller of the function.

Syntax

A function call is performed using the name of the function followed by a (possibly empty) list of arguments in parenthesis.

    function-name(variable-list);

Example

    println("Hello!");

or

    charCode = readChar();