Syntax of Variable Declarations

Figure 3.1. variableDeclaration

variableDeclaration

Figure 3.2. typeSpecifier

typeSpecifier

Figure 3.3. initializingExpression

initializingExpression

Table 3.1. Variable Modifiers

packageThe variable can only be accessed within the package where it is defined. See Access Modifiers.
protectedThe variable can be accessed from the package where it is defined and from subclasses of the class where it is defined. See Access Modifiers.
publicThe variable can be accessed anywhere. See Access Modifiers.
public-readThe var can be read anywhere. See Access Modifiers.
public-initThe var can be initialized or read anywhere. Where initialized means set (but not bound) in an object literal. See Access Modifiers.

While syntactically optional, an initializingExpression is required with def.

When bind is specified in the initializingExpression the variable is kept updated to the value of the expression. When with inverse is specified, the expression must be a simple variable reference and that variable is kept updated when the variable being declared is changed. See the Binding chapter for details.