Using public properties instead of public variables

Although Gosu supports public variables for compatibility with other languages, best practice is to use public properties backed by private variables instead of using public variables. To define the public property name to use to access the data, you use the syntax as PROPERTY_NAME at the end of the declaration.

For example, to declare a public property, use this style of variable declaration:

private var _firstName : String as FirstName

Do not declare a public field:

public var FirstName : String   // Do not do this. Public variables are not standard Gosu style

See also