Operators
Built-in operations that can be applied to primitive values.
Unary Operators
These are operations involving only a single expressions.
Negate (-)
Used to negate a numeric value; negative values become positive and positive values become negative.
Absolute (+)
Used to get the absolute version of a numeric value; negative values become positive.
Not (!)
Used to invert a boolean value; true
values become false
and false
values become true
.
Binary Operators
These are operations involving both a left-hand side and a right-hand side expression.
Logical Operators
These operations are used to compare boolean
values.
Logical AND (&&)
This operation evaluates to true
if both the left-hand and right-hand expressions evaluate to true
and false
otherwise.
Logical OR (||)
This operation evaluates to true
if either the left-hand or right-hand expressions evaluate to true
and false
otherwise.
Comparative Operators
These operations are used to compare numeric (integer
and float
) values.
These operators can compare values with asymmetric types, meaning that an integer
can be compared directly to a float
.
Less Than or Equal (<=)
This operation evaluates to true
if the left-hand value is less than or equal to the right-hand value and false
otherwise.
Less Than (<)
This operation evaluates to true
if the left-hand value is less than the right-hand value and false
otherwise.
Greater Than or Equal (>=)
This operation evaluates to true
if the left-hand value is greater than or equal to the right-hand value and false
otherwise.
Greater Than (>)
This operation evaluates to true
if the left-hand value is greater than the right-hand value and false
otherwise.
Arithmetic Operators
These operations are used to perform basic arithmetic (add, subtract, divide, etc.) on numeric types (integer
and float
).
These operators can compare values with asymmetric types, meaning that an integer
can be compared directly to a float
.
Add (+)
This operation adds two numeric values together. If either value is a float
then the resulting type is also float
otherwise it is integer
.
Subtract (-)
This operation subtracts one numeric value from another. If either value is a float
then the resulting type is also float
otherwise it is integer
.
Multiply (*)
This operation multiplies two numeric values together. If either value is a float
then the resulting type is also float
otherwise it is integer
.
Divide (/)
This operation divides one numeric value by another. No matter the type of the left-hand or right-hand values the result is always of type float
.
Exponentiation (^)
This operation calculates one numeric value to the power of another. No matter the type of the left-hand or right-hand values the result is always of type float
.
Equality Operators
Used to compare values of all types with each other. The values on either side of the operator must be of the same type.
Equal (==)
This operation returns true
if two values are the same and false
otherwise.
Not Equal (!=)
This operation returns true
if two values are not the same and false
otherwise.
Last updated