Static members

Gosu supports static members on a type. Static members include variables, functions, property declarations, and static inner classes on a type. A static member exists only once, on the type, not on instances of the type.

To declare a type as static for a new Gosu class, use the static keyword, as in Java.

The syntax for using a static member is to use the period (.) character followed by the property name or method call after a type reference, which is the type name. For example, the following code accesses a static property and calls a static method:

var myVar = MyClass.MY_CONST // Get a static property value
MyClass.staticMethodName()   // Call a static method 

Alternatively, to use the static members without qualifying them with the class name, you use the syntax of the uses statement that imports static members. For example, the following code is equivalent to the previous lines:

uses MyClass#*
...
var myVar = MY_CONST // Get a static property value
staticMethodName()   // Call a static method 

See also