Optional Parts

A method declaration can have any number of optional parts. When calling a method, optional parts can be omitted. Optional parts are identified by enclosing them into square brackets ([ ]) at the end of the method declaration. Here's an example of a method definition with one optional part:

(int) minimum of <int a>, <int b> [ , <int c = int.maximum value> ]

Optional part must have at least one parameter and some text also, and each parameter must have a default value defined. When calling the method with a optional part left out, the default values of its parameters are used.

The mandatory text part above is comma "," and the mandatory parameter is <int c = int.maximum value> with int.maximum value as the default value. You may call the function without the optional part:

int minimum = minimum of 7, 5

or with it:

int minimum = minimum of 7, 5, 13