5.3 Constants

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:

ExampleTypeNote
42, 0xFF42Intinteger constant
0.32, 3., 2.1e5Floatfloating-point decimal constant
true, falseBoolboolean constant
~/haxe/giERegregular expression
nullTnull value for any nullable type
"XXX", 'XXX'Stringstring literal
"X".code, 'X'.codeIntUnicode character codepoint
MyEnum.HaxeTenum constructor with no arguments

Furthermore, the internal syntax structure treats identifiers as constants, which may be relevant when working with macros.