Function Syntax

Examples

Your function can compute values and store them in local variables that are specific to the function. Those values can then be returned with the return statement.

The return statement also can be shortened for very simple functions into a single line

You can simplify the function further. The last expression that is evaluated is automatically returned by the method. For example:

This would return the same value as the prior functions.

To call a function

or

Example