Unary Operators

Unary expressions are expressions where an Operator is combined with a single other expression. Unary operators can be pre-fix, meaning they come before the expression they operate on, or post-fix, meaning they come after the expression.

Except for the ^ Pointer Dereference Operator, all unary operators in Oxygene are pre-fix.

Examples:

var a := true;
var b := not a; // result: false

var x := 5;
var y := -x; // result: -5

var f: block := @MyMethod;

var i: ^Integer;
i^ := 5; // de-references  the pointer

Operators

The table below lists all available unary operators.

Operator Description
not Reverses the value of a Boolean from true to false or vise versa
Reverses each bit of an Integer value from 0 to 1 or vice versa.
- Turns a positive Integer value negative, or a negative one positive.
+ Opposite of negation (-), generally does nothing for most types.
@ The Address Of operator.
^ The Pointer Dereference operator.
old The old Operator, can be used to refer to the original value of a parameter or Field in a Post-Condition.
inherited Allows access to the inherited version of the expression it precedes. Available for Member Access and constructor Calls

For the +, - and not operators, Custom Types can implement Custom Operators that provide type-specific behavior.

See Also