Appendix C. Operator Precedence

An operator is a symbol that denotes a function or operation

Each operator has it's own precedence level. Here is a table showing the operator precedence.

Operator Name Type Syntax Description
() Invoke Unary <target>(<arguments>) Invokes a function.
[] Index Binary <target>[<index>] Gets the value of the index.
-- Postix-Decrement Unary <target>-- Returns, then decrements the target by one.
++ Postfix-Increment Unary <target>++ Returns, then increments the target by one.
. Attribute Access Binary <target>.<attribute> Gets the attribute in target.
-- Prefix-Decrement Unary --<target> Decrements the target by one, then returns.
++ Prefix-Increment Unary ++<target> Increments the target by one, then returns.
- Negate Unary -<target> Returns the negative value of the target.
& Reference Unary &<target> Returns a pointer to target.
* Dereference Unary *<target> Returns the value from the pointer.
~ Bitwise-Not Unary ~<target> Returns the bitwise complement of the target.
! Logical-Not Unary !<target> Returns the boolean compliment of the target.
* Multiplication Binary <left>*<right> Returns left multiplied by right.
** Power Binary <left>**<right> Returns left to the power of right.
/ Division Binary <left>/<right> Returns left divided by right.
// Integer-Division Binary <left>//<right> Returns left divided by right, rounded.
% Modulus Binary <left>%<right> Returns the remainder of left divided by right.
?? Null-Coalescing Binary <left>??<right> Returns the left if left i not null, otherwise returns right.
is Type checking Binary <left>is<right> Returns a bool indicating if left is of type right.
+ Addition Binary <left>+<right> Returns left plus right.
- Subtraction Binary <left>-<right> Returns left minus right.
<< Bitshift-Left Binary <left><<<right> Returns left shifted left by right bits.
>> Bitshift-Right Binary <left>>><right> Returns left shifted right by right bit.
& Bitwise-And Binary <left>*<right> Returns the bitwise and of left and right.
^ Bitwise-Xor Binary <left>^<right> Returns the bitwise xor of left and right.
<pipe> Bitwise-Or Binary <left><pipe><right> Returns the bitwise or of left and right.
> Greater-Than Binary <left>><right> Returns a bool if left is greater than right.
>= Greater-Than-Or-Equal Binary <left>><right> Returns a bool if left is greater than or equal to right.
< Lesser-Than Binary <left><<right> Returns a bool if left is lesser than right.
<= Lesser-Than-Or-Equal Binary <left><=<right> Returns a bool if left is lesser than or equal to right.
== Equal-To Binary <left>==<right> Returns a bool if left equals right.
!= Not-Equal-To Binary <left>!=<right> Returns a bool if left is not equal to right.
&& Logical-And Binary <left>&&<right> Returns a bool indicating if left and right are true.
<pipe><pipe> Logical-Or Binary <left><pipe><pipe><right> Returns a bool indicating if left or right are true.
? : Conditional Ternary <target>?<left>:<right> Returns left if target is true, otherwise right.
= Assignment Binary <left>=<right> Assigns right to left and returns right.
+=, -=, *=, /=, %=, <<=, >>=, &=, ^= Operation-Assignment Binary <left><op><right> Assigns left right to left.
<=> Swap Binary <left><=><right> Swaps the values of left and right.

results matching ""

    No results matching ""