When defining a structure type, Haxe allows the use of the same syntax described in Class Fields. The following typedef declares a Point
type with variable fields x
and y
of type Int
:
typedef Point = { var x : Int; var y : Int; }
The fields of a structure may also be declared with final
, which only allows them to be assigned once. Such a structure will only unify with other types if the corresponding fields are also final
.