Skip to content

Latest commit

 

History

History
19 lines (14 loc) · 852 Bytes

5.10.var.md

File metadata and controls

19 lines (14 loc) · 852 Bytes

5.10.var

var 关键字允许声明多个变量,通过逗号分隔。每个变量有一个有效的标识符(第5章),可选的可以有一个值分配,跟在赋值操作符 = 之后。变量也可以有一个显式的类型标记。

The var keyword allows declaring multiple variables, separated by comma ,. Each variable has a valid identifier (5) and optionally a value assignment following the assignment operator =. Variables can also have an explicit type-hint.

var a; // declare local a 
var b:Int; // declare variable b of type Int 
// declare variable c, initialized to value 1 
var c = 1; 
// declare variable d and variable e 
// initialized to value 2 
var d,e = 2;

局部变量的作用于行为在块(第5.1节)中描述。

The scoping behavior of local variables is described in Blocks (Section 5.1).