Chapter 4. Functions

Functions are defined as follows:

func (arguments) statement
func (arguments)
    statements
end

A variable name may be specified after the func keyword to assign the function to that variable.

A return statement inside a function stops the function and returns a given value. A return statement without a value returns nil, as does reaching the end of the function.

Yewslip> func factorial(n)
    ...>     if n > 1 then return factorial(n - 1) * n
    ...>     return 1
    ...> end

Yewslip> print factorial(5)
120