| Operator | Usage | Description |
|---|---|---|
= | x = 5 | Assign value (also used for equality in expressions) |
| (space) | x 5 | Assign value without = |
In a statement context (start of line, after identifier), = is assignment. In an expression context (inside if, etc.), = is equality comparison.
| Operator | Example | Result |
|---|---|---|
+ | 5 + 3 | 8 |
- | 5 - 3 | 2 |
* | 5 * 3 | 15 |
/ | 10 / 3 | 3.3333... |
% | 10 % 3 | 1 |
The + operator concatenates strings:
If either operand is a string, the other is converted to string automatically:
| Operator | Meaning | Example |
|---|---|---|
= | Equal | x = 5 |
!= | Not equal | x != 5 |
< | Less than | x < 10 |
> | Greater than | x > 10 |
<= | Less or equal | x <= 10 |
>= | Greater or equal | x >= 10 |
All comparison operators return t or f.
| Operator | Meaning | Example |
|---|---|---|
& | AND | a & b |
| | OR | a | b |
! | NOT | !a |
From lowest to highest:
| Precedence | Operators |
|---|---|
| 1 (lowest) | | |
| 2 | & |
| 3 | = != |
| 4 | < > <= >= |
| 5 | + - |
| 6 | * / % |
| 7 | ! - (unary) |
| 8 (highest) | () [] . (call, index, access) |
Use parentheses to override precedence: