Assign Statements

The assign statements – expressed as :=, a colon followed by an equal sign – assigns the value of the expression on right to the writable expression on the left.

x := 5;

After the above statement, x has a value of 5.

Different from most other languages, Pascal and Oxygene purposely do not use the equal sign for assignment, to highlight the active nature of the statement – it is not expressing equality, but transferring a value (even if the end result – usually, but not always – is equality of the left and the right).

The left side of the assign statement must be a writable expression, while the right side can be any kind of Expression.

Writable expressions include:

Note that in particular for Properties with custom setter code, and for Discardables, the end result of an assignment is not necessarily equality. For example, a property setter (or getter) code might modify the actual value.

Other uses of the := Operator

The assignment operator can also appear in other statements that are not stand-alone assign statements such as:

Notably, Consts use the = operator to specify their value, and not :=, since for constants, equality between the constant and the literal it is being initialized with is guaranteed, and a fundamental part of what makes them constants.

See Also