Skip to content

Latest commit

 

History

History
38 lines (29 loc) · 2.65 KB

5.2.常量.md

File metadata and controls

38 lines (29 loc) · 2.65 KB

5.2.常量

Haxe语法支持下面的常量:

The Haxe syntax supports the following constants:

Int:一个整型(第2.1.1节),例如0,1,97121,-12, 0xFF0000 。 Float:一个浮点数(第2.1.1节),如0.0,1.,.3,-93.2 。 String:一个字符串(第10.1节),如"",“foo”,'','bar' 。 true,false:一个布尔值 null:null值

Int: An integer (2.1.1), such as 0, 1, 97121, -12, 0xFF0000. Float: A floating point number (2.1.1), such as 0.0, 1., .3, -93.2. String: A string of characters (10.1), such as "", "foo", ’’, ’bar’. true,false: A boolean (2.1.4) value. null: The null value.

此外,内部的语法结构将标识符作为常量,可能在使用宏(第9章)时是相关的。

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

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.