Constants are values which are immutable. These values can be used as inline variables and default values for function arguments. All constants are literals, except for argument-less enum constructors:
Example | Type | Note |
---|---|---|
42 , 0xFF42 | Int | integer constant |
0.32 , 3. , 2.1e5 | Float | floating-point decimal constant |
true , false | Bool | boolean constant |
~/haxe/gi | EReg | regular expression |
null | T | null value for any nullable type |
"XXX" , 'XXX' | String | string literal |
"X".code , 'X'.code | Int | Unicode character codepoint |
MyEnum.Haxe | T | enum constructor with no arguments |
Furthermore, the internal syntax structure treats identifiers as constants, which may be relevant when working with macros.