Core Features
Operators
Learn about the operators Cambo supports.
Operators are symbols or keywords that instruct the compiler to perform mathematical, logical, or relational manipulations on data. And the values or variables that operators act upon are called operands.
There are commonly three types of operators categorized by the number of operands:
- Unary: operates on a single operand.
- Binary: operates on two operands.
- Ternary: operates on three operands.
This page provides a complete list of all of the available operators supported by Cambo.
A full version of this page has not documented!
Built-in Operators
Arithmetic Operators
| Operator | Type | Desciption | Example |
|---|---|---|---|
| - | Unary | Inverts the sign of a number | -a |
| ++ | Unary | Increases the value of a variable by 1 | a++ or ++a |
| -- | Unary | Decreases the value of a variable by 1 | a-- or --a |
| + | Binary | Adds together two values | a + b |
| - | Binary | Substract one value from another | a - b |
| * | Binary | Multiplies two values | a * b |
| / | Binary | Divide one value by another | a / b |
| % | Binary | Returns the division remainder | a % b |
| ** | Binary | One value raised to the power of another | a ** b |
Assignment Operators
| Operator | Type | Desciption | Example | Equivalent To |
|---|---|---|---|---|
| = | Binary | Assign | a = b | a = b |
| += | Binary | Add and assign | a += b | a = a + b |
| -= | Binary | Substract and assign | a -= 1 | a = a - b |
| *= | Binary | Multiply and assign | a *= 1 | a = a * b |
| /= | Binary | Divide and assign | a /= 1 | a = a / b |
| %= | Binary | Modulus and assign | a %= 1 | a = a % b |
| **= | Binary | Power and assign | a **= b | a = a ** b |
| &= | Binary | Bitwise AND and assign | a &= b | a = a & b |
| |= | Binary | Bitwise OR and assign | a |= b | a = a | b |
| ^= | Binary | Bitwise XOR and assign | a ^= b | a = a ^ b |
| >>= | Binary | Left shift and assign | a >>= b | a = a >> b |
| <<= | Binary | Right shift and assign | a <<= b | a = a << b |
Comparision Operator
| Operator | Type | Name | Example |
|---|---|---|---|
| == | Binary | Equal to | a == b |
| != | Binary | Not equal | a != b |
| > | Binary | Greater than | a > b |
| < | Binary | Less than | a < b |
| >= | Binary | Greater than or equal to | a >= b |
| <= | Binary | Less than or equal to | a <= b |
Logical Operator
Operands must be boolean expressions.
| Operator | Type | Name | Desciption | Example |
|---|---|---|---|---|
| ! | Unary | Logical not | Reverse the result, returns false if the result is true | !a |
| && | Binary | Logical and | Returns true if both statements are true | a && b |
| || | Binary | Logical or | Returns true if one of the statements is true | a || b |