Static methods and variables

If you want to call a method directly on the class itself rather than an instance of the class, you can provide a static method. To declare a method as static, add the keyword static before the function declaration. You use similar syntax to make a variable static. For example, this Gosu code declares an instance method:

public function doAction(arg1 : String)

This Gosu code declares a static method:

static public function doAction(arg1 : String)

Gosu does not support a class having both an instance method and a static method that have the same name and argument list.

Gosu classes can also contain static values.

See also