Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

11.2.1Accepting parameters

Each function parameter is declared with its type, separated by a colon. Multiple parameters are separated by commas.

Here is an example with one integer parameter:

The number is 5

Here is an example with two parameters:

The number is 5.
The character is Z.

11.2.2Parameter mutability

Any parameter can be declared mutable in order to allow its modification inside the function:

The number is 15.

11.2.3Returning a value

The most used form for returning a value is by writing an expression at the end of the function, without a semicolon. The type of the returned value must be declared using the -> symbol:

6

Since the if statement can also be used to build an expression, we can use it to return a value conditionally:

64

11.2.4The return keyword

The return keyword is used to leave the function. It can be used anywhere inside the function’s scope:

The number is 6.

The return keyword can also return a value:

6