要声明静态属性,将关键字static放在可见度修饰符后面,直接位于属性变量前面。
To declare a static property, place the keyword static after the visibility modifier, directly in front of the property variable.
$onlyOne 之前的静态修饰符将此变量关系到类本身。
The static modifier that precedes $onlyOne ties the variable to the class itself.
注释是可以添加到代码中的修饰符,可以用于包声明、类型声明、构造函数、方法、字段、参数和变量。
Annotations are modifiers you can add to your code and apply to package declarations, type declarations, constructors, methods, fields, parameters, and variables.
请注意,关键字“def”在这儿作为一个实例变量的修饰符使用,指明变量是属性。
N.B. the keyword "def", used here as an instance variable modifier, indicates that the variables are properties.
使用关键字register修饰最经常使用的变量:告诉编译器这个变量将会被经常用到,要求编译器使用非常高的优先级将此变量分配到寄存器中。
Using register for frequently-used variables: this tells the compiler that the register variable is going to be frequently used, so it should be allocated to a register with a very high priority.
在这个类中关键字def被作为局部变量修饰符使用。
In this class the keyword def is being used as a local variable modifier.
例如,Groovy不要求使用分号,变量类型和访问修饰符也是可选的。
For example, Groovy doesn't require semicolons, and it makes variable types and access modifiers optional.
除非一个实例变量被标注修饰,否则他将成为一个瞬时变量。
Unless an instance variable is decorated with an annotation, it will be a transient instance variable.
除非一个实例变量被标注修饰,否则他将成为一个瞬时变量。
Unless an instance variable is decorated with an annotation, it will be a transient instance variable.
应用推荐