Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The haxe compiler uses type inference to infer (deduce) the type from values you assign to a variable.
- This relieves you from the burden to strongly type all your variables without losing strong typing.
- For example, the following code:
- var f = 10.5;
- var s = "foo";
- var arr = ["hello", "world"];
- will be compiled as if you had written:
- var f:Float = 10.5;
- var s:String = "foo";
- var arr:Array<String> = ["hello", "world"];
- (Mostly) for debugging purposes, you can check at compile time which type the compiler deduced, by using the special identifier '$type'.
- We'll use it in the rest of this explanation to show how the compiler infers types.
Advertisement
Add Comment
Please, Sign In to add comment