Cerberus X Documentation

Keyword Function

Declares the beginning of a function.

Syntax

Function Identifier: ReturnType ( Parameters )
Statements...
End [ Function ]

Description

The Function keyword begins the declaration of a function.

Please see the Functions section of the Cerberus X language reference for more information on functions.

See also

End
Language reference (Functions)
Language reference (Strict mode)

Examples

The Main function, required by all Cerberus X programs.

Function Main ()
Print "Hello"
End

The closing keyword End may be replaced with End Function if preferred:

Function Main ()
Print "Hello"
End Function

The Main function in Strict mode; requires Int return type and Return statement.

Strict

Function Main:Int ()
Print "Hello"
Return 0
End

A function that returns the result of adding two floating-point values.

Function AddFloats:Float (value1:Float, value2:Float)
Return value1 + value2
End

Print AddFloats (1, 2)

For functions that don't return a value in Strict mode, the Void return type must be specified in the function declaration.

Strict

Function PrintMessage:Void (message:String)
Print message
End