Assignments
Variables or fields can be assigned locally in functions, permissions, obligations, in any block-like construct, or as fields of a protocol.
Initialization
Parameters of a protocol, a permission, an obligation or a function are initialized at instantiation or execution with
an argument value. This includes protocol fields and variables. Its syntax starts with the var
keyword followed by the
identifier name followed by the =
operator. Declaring the type is optional. The syntax to do so is shown in the
example below.
For example:
var n = 2;
Mutability
The assignment of parameters, fields, and variables is mutable by default. Reassignment is accomplished using the =
operator, e.g.:
var n = 2;
var o: Number = 2;
n = 3;
Note that assignments are mutable. For example, it is not legal to reassign values in an instantiated struct, or mutate an instantiated collection.