Operators
Arithmetic Operators
| Operator | Description | Example |
|---|
+ | Addition | a + b |
- | Subtraction | a - b |
* | Multiplication | a * b |
/ | Division | a / b |
% | Modulo | a % b |
- (unary) | Negation | -a |
Comparison Operators
| Operator | Description | Example |
|---|
== | Equal | a == b |
!= | Not equal | a != b |
< | Less than | a < b |
<= | Less than or equal | a <= b |
> | Greater than | a > b |
>= | Greater than or equal | a >= b |
Logical Operators
| Operator | Description | Example |
|---|
and | Logical AND | a and b |
or | Logical OR | a or b |
not | Logical NOT | not a |
Kira uses keywords instead of symbols for logical operators. This is part of the "no surprises" philosophy — keywords are unambiguous.
Other Operators
| Operator | Description | Example |
|---|
+ | String concatenation | "a" + "b" |
?? | Null coalesce | opt ?? default |
? | Try (error propagation) | result? |
. | Field/method access | obj.field |
[] | Type argument | List[i32] |
Operator Precedence (Highest to Lowest)
. (field access), [] (type arguments)
- (unary negation), not
*, /, %
+, -
<, <=, >, >=
==, !=
and
or
??
?