Operators

The following table lists all of the User Language operators, in order of their precedence; Unary having the highest precedence, Comma the lowest:

   
Unary ! ~ + - ++ --
Multiplicative * / %
Additive + -
Shift << >>
Relational < <= > >=
Equality == !=
Bitwise AND &
Bitwise XOR ^
Bitwise OR `
Logical AND &&
Logical OR `
Conditional ?:
Assignment = *= /= %= += -= &= ^=
Comma ,

Associativity is left to right for all operators, except for Unary, Conditional and Assignment, which are right to left associative.

The normal operator precedence can be altered by the use of parentheses.

Bitwise Operators

Bitwise operators work only with data types char and int.

Unary

   
~ Bitwise (1's) complement

Binary

   
<< Shift left
>> Shift right
& Bitwise AND
^ Bitwise XOR
` `

Assignment

   
&= Assign bitwise AND
^= Assign bitwise XOR
` =`
<<= Assign left shift
>>= Assign right shift

Logical Operators

Logical operators work with expressions of any data type.

Unary

   
! Logical NOT

Binary

   
&& Logical AND
`

Using a string expression with a logical operator checks whether the string is empty.

Using an Object Type with a logical operator checks whether that object contains valid data.

Comparison Operators

Comparison operators work with expressions of any data type, except Object Types.

   
< Less than
<= Less than or equal to
> Greater than
>= Greater than or equal to
== Equal to
!= Not equal to

Evaluation Operators

Evaluation operators are used to evaluate expressions based on a condition, or to group a sequence of expressions and have them evaluated as one expression.

   
?: Conditional
, Comma

The Conditional operator is used to make a decision within an expression, as in

int a;
// ...code that calculates 'a'
string s = a ? "True" : "False";

which is basically the same as

int a;
string s;
// ...code that calculates 'a'
if (a)
   s = "True";
else
   s = "False";

but the advantage of the conditional operator is that it can be used in an expression.

The Comma operator is used to evaluate a sequence of expressions from left to right, using the type and value of the right operand as the result.

Note that arguments in a function call as well as multiple variable declarations also use commas as delimiters, but in that case this is not a comma operator!

Arithmetic Operators

Arithmetic operators work with data types char, int and real (except for ++, --, % and %=).

Unary

   
+ Unary plus
- Unary minus
++ Pre- or postincrement
-- Pre- or postdecrement

Binary

   
* Multiply
/ Divide
% Remainder (modulus)
+ Binary plus
- Binary minus

Assignment

   
= Simple assignment
*= Assign product
/= Assign quotient
%= Assign remainder (modulus)
+= Assign sum
-= Assign difference

String Operators

String operators work with data types char, int and string. The left operand must always be of type string.

Binary

   
+ Concatenation

Assignment

   
= Simple assignment
+= Append to string

The + operator concatenates two strings, or adds a character to the end of a string and returns the resulting string.

The += operator appends a string or a character to the end of a given string.