Skip to end of metadata
Go to start of metadata

Parameters are the objects you can pass to Functions, Closures, or Callable Types which handle Events.

A parameter is declared with a name, followed by "as", followed by the type: paramname as type. If there is no "as type", then the type is assumed to be type object.

Examples

Method/Function example

Closure

Callable Type + Event

Variable number of parameters

Boo allows you to call or declare methods that accept a variable (unknown) number of parameters.

You add an asterix (*) before the parameter name to signify that it holds multiple parameter values. If there is no 'as type', the type is assumed to be an array of objects: (object). You can declare the type as any array type. For example (int) if your method only accepts int parameters.

Here is an example:

Some boo builtins accept a variable number of parameters, like matrix() and ICallable.Call.

ByRef parameters

Add a "ref" keyword before the parameter name to make a parameter be passed by reference instead of by value. This allows you to change a variable's value outside of the context where it is being used. Some examples:

Basic byref example:

DllImport example:

Wrapping a native method that takes a parameter by reference.

See also tests/testcases/integration/byref*.boo in the boo source distribution.

  • No labels