2.3 Class Instance

Similar to many object-oriented languages, classes are the primary data structure for the majority of programs in Haxe. Each Haxe class has an explicit name, an implied path and zero or more class fields. Here we will focus on the general structure of classes and their relations, while leaving the details of class fields for Class Fields.

The following code example serves as basis for the remainder of this section:

This type is compatible with all class types which means that all classes (not their instances) can be assigned to it. At compile-time, Class<T> is the common base type of all class types. However, this relation is not reflected in generated code.

This type is useful when an API requires a value to be a class, but not a specific one. This applies to several methods of the Haxe reflection API.