Skip to main content

Parameters & Return Types

Methods accept parameters using name as type syntax and return values using as type.


Parameter Syntax

Every parameter has the form name as type:

Greet method(name as string) {
Print("Hello, " + name + "!");
}

Add method(a as int, b as int) as int {
return a + b;
}

Multiple Parameters

Separate parameters with commas:

CreateVector method(x as float, y as float, z as float) as Vector3 {
// ...
}

Method Type Parameters

You can pass a method as a parameter type:

Execute method(action as method) {
action();
}

See Callbacks for more details.


Return Type

Use as after the parameter list:

GetName method() as string {
return "Morph";
}

Square method(x as int) as int {
return x * x;
}

No Return Type (Void)

Omit as if the method returns nothing:

PrintHello method() {
Print("Hello!");
}

Returning Values

Use return to send a value back to the caller:

Max method(a as int, b as int) as int {
if (a > b) {
return a;
}
return b;
}

Next Steps