Operators
Each operator has a precedence value. When an operator is part of an expression, it will bind more tightly to its operands the higher its precedence value.
# Since "*" has higher precedence than "+",
# it will bind more tightly to 2 and 3,
# so this expression is evaluated (1 + (2 * 3))
1 + 2 * 3
Precedence 8
Power (**)
int ** int
Returns left to the power of right.
Note: Power is left associative.
Precedence 7
Multiply (*)
int * int
Returns left multiplied by right.
Divide (/)
int / int
Returns left divided by right.
Modulo (%)
int % int
Returns the remainder of dividing left by right.
Precedence 6
Add (+)
int + int
Returns left plus right.
string + string
Returns the concatenated string, left followed by right.
array + array
Returns the merged array containing all of left's values followed by all of right's values.
object + object
Returns left merged with right, with duplicate keys taking the value from right.
Subtract (-)
int - int
Returns left minus right.
Precedence 5
Left shift (<<)
int << int
Returns left, with all the bits in it shifted left, right amount of times.
Equivalent to left * (2 ** right).
See wikipedia for more details.
array << any
Returns left with right appended to it.
If left is a variable, it mutates it.
Right shift (>>)
int >> int
Returns left, with all the bits in it shifted right, right amount of times.
Equivalent to left / (2 ** right).
See wikipedia for more details.
any >> array
Returns right with left prepended to it.
If right is a variable, it mutates it.
Precedence 4
Less than (<)
sizeable < sizeable
Returns a boolean value, whether size of left is less than size of right.
Greater than (>)
sizeable > sizeable
Returns a boolean value, whether size of left is greater than size of right.
Less than or equal (<=)
sizeable < sizeable
Returns a boolean value, whether size of left is less than or equal to size of right.
Greater than or equal (>=)
sizeable > sizeable
Returns a boolean value, whether size of left is greater than or equal to size of right.
Three-way comparison (<=>)
sizeable <=> sizeable
If size of left is greater than right, it returns an integer of value 1.
If size of left is lesser than right, it returns an integer of value -1.
If the size of both sides match, it returns an integer of value 0.
Precedence 3
Equal (==)
any == any
Returns a boolean value, whether left is equal to right.
Not equal (!=)
any != any
Returns a boolean value, whether left is not equal to right.
Precedence 2
Logical and (&&/and)
any && any
If left is truthy, return right. Otherwise, return left.
Logical or (||/or)
any || any
If left is truthy, return left. Otherwise, return right.
Precedence 1
Assign (=)
variable = any
Sets the value of left to right.
Operator assignments (+=/-=/*=//=/%=)
variable <operator>= any
Sets the value of left to the result of <operator> evaluated on left and right.
x = 1
x += 2 # x == x + 2 == 3