Overview of interfaces
Gosu supports interfaces, including full support
for Java interfaces. An interface is a set of method signatures that
a type must implement. An interface defines a contract that specifies
the minimum set of functionality to be considered compatible. To define
an interface, use the interface
keyword, then the interface name, and then a set of method signatures
without function bodies. The following Gosu code uses the interface keyword to define a
simple interface:
package example
interface ILoadable {
function load()
}
A class can implement the interface with the implements keyword followed by
a comma-delimited list of interfaces. A class that implements an interface
contains all methods in the interface, as shown in the following code:
package example
class LoadableThing implements ILoadable {
function load() {
print("Loading...")
}
}
See also
