变量类型
1. 基本类型
var a:Int = 10;var b:Float = 3.14;var isTrue:Bool = true;var str:String = "Hello, Haxe!";var nullable:Int = null; var nonNullable:Null<Int> = null;
2. 复杂类型
var numbers:Array<Int> = [1, 2, 3, 4];var map:Map<String, Int> = ["one" => 1, "two" => 2];enum Color { Red; Green; Blue; Custom(rgb:Int); } var c:Color = Color.Red;class Person { public var name:String; public function new(name:String) { this.name = name; } } var p:Person = new Person("Alice");
3. 其他类型
4. 结构类型 (Anonymous Structure)
5. 抽象类型 (Abstract Types)
6. 类型推断
7. Typedef
8. 联合类型
总结
Last updated