Keyword Field

Declares a class field variable.


Field Identifier:Type [ = Expression ]

Field Identifier:= Expression


The Field keyword declares an instance variable within a custom class. The field is valid for the lifetime of the object it belongs to.

A field's default value upon object creation can be set in the field's declaration.

To access an object's fields, use the syntax object.field. (See example.)

The alternative syntax provided allows the variable's type to be deduced from the expression.

See also

Const | Local | Global
Language reference


' Declaring class and fields
Class Player 
    Field name:String 
    Field points:Int = 0 
' Creating object "p" of type "Player"
Local p:Player = New Player 
' Accessing fields = "Mary" 
p.points = 100 
Print p.points