Symbol |
Precedence |
Function |
Number of Operands |
Description |
:= |
0 |
Assignment |
2 |
Assigns the value of an expression on
the right to the variable or array element on the left. Right-associative. The value of the
assignment is the right-most operand. Supports multiple assignment i.e.
a := b := c := 0 sets all
3 variables to zero. Assignment to an array variable creates a copy of the right-hand operand. |
|| |
1 |
Logical Or |
2 |
True if either expression is true |
&& |
2 |
Logical And |
2 |
True if both expressions are true |
+= |
2 |
Add and Assign |
2 |
Adds the expression on the right to the variable or array
element on the left. |
*= |
2 |
Multiply and Assign |
2 |
Multiplies the variable or array element on the left by the
expression on the right |
/= |
2 |
Divide and Assign |
2 |
Divides the variable or array element on the left by the
expression on the right. |
^= |
2 |
Exponent and Assign |
2 |
Raises the variable or array element on the left to the power
of the expression on the right |
: |
3 |
Slice/Range |
2 |
Specifies
a range of elements in a string or array. For strings, creates a
substring. For arrays, creates a copy of the elements within the range.
Range includes the upper element. For strings,
negative indices start at the last element and count backwards. |
== |
4 |
Equality |
2 |
True if the operands are equal.
Operands must be comparable to each other. |
!= |
4 |
Inequality |
2 |
True if the operands are not equal. |
> |
5 |
Greater Than |
2 |
Operands must be comparable and ordered. For strings,
comparison is case-insensitive. |
< |
5 |
Less Than |
2 |
For strings, case-insensitive. |
>= |
5 |
Greater or Equal |
2 |
For strings, case-insensitive. |
<= |
5 |
Less than or Equal |
2 |
For strings, case-insensitive. |
| |
6 |
Bitwise Or |
2 |
Performs a bitwise or, demoting the operands to integers |
& |
7 |
Bitwise And |
2 |
Performs a bitwise and, demoting the operands to integers. |
<< |
8 |
Binary Left Shift |
2 |
Shifts left operand left by specified number of bits,
demoting both operands to integers. |
>> |
8 |
Binary Right Shift |
2 |
Shifts left operand right by specified number of bits,
demoing both operands to integers. |
+ |
9 |
Addition/Concatentation |
2 |
Adds two numbers or joins two strings. |
- |
9 |
Subtraction |
2 |
Self-explanatory. |
|
10 |
Multiplication |
2 |
Self-explanatory. |
/ |
10 |
Division |
2 |
Self-explanatory. |
% |
10 |
Modulo |
2 |
Returns the remainder of integer division. |
^ |
11 |
Exponentiation |
2 |
Raises left operand to the power of the right operand. |
- |
12 |
Negation |
1 |
Returns the opposite of an expression. |
$ |
12 |
Stringize |
1 |
Returns a string representation of an expression. (Shorthand
for ToString). |
! |
13 |
Logical Not |
1 |
Returns the opposite of a boolean expression. i.e. !(true) evaluates to false. |
( ) |
14 |
Parentheses |
0 |
Enclose expressions within parentheses to override default
precedence rules. |
[ ] |
15 |
Subscript |
2 |
For
arrays, accesses the element having the specified key. For strings,
returns a string containing the single character at the specified
position. The expression within the brackets is treated as if it were
parenthesized (overrides precedence rules). |