Appendix B: Operators and Symbols
In this chapter, we'll explore mana's operators and symbol reference.
Appendix B: Operators and Symbols
This appendix contains a glossary of Mana's operators and symbols.
Arithmetic Operators
| Operator | Example | Description |
|---|
+ | a + b | Addition |
- | a - b | Subtraction |
* | a * b | Multiplication |
/ | a / b | Division |
% | a % b | Remainder (modulo) |
** | a ** b | Exponentiation (power) |
Comparison Operators
| Operator | Example | Description |
|---|
== | a == b | Equal to |
!= | a != b | Not equal to |
< | a < b | Less than |
> | a > b | Greater than |
<= | a <= b | Less than or equal to |
>= | a >= b | Greater than or equal to |
Logical Operators
| Operator | Example | Description |
|---|
&& | a && b | Logical AND |
|| | a || b | Logical OR |
! | !a | Logical NOT |
Bitwise Operators
| Operator | Example | Description |
|---|
& | a & b | Bitwise AND |
| | a | b | Bitwise OR |
^ | a ^ b | Bitwise XOR |
~ | ~a | Bitwise NOT |
<< | a << b | Left shift |
>> | a >> b | Right shift |
Assignment Operators
| Operator | Example | Equivalent |
|---|
= | a = b | Assign b to a |
+= | a += b | a = a + b |
-= | a -= b | a = a - b |
*= | a *= b | a = a * b |
/= | a /= b | a = a / b |
%= | a %= b | a = a % b |
Other Operators
| Operator | Example | Description |
|---|
? | value? | Error propagation |
?? | a ?? b | Null coalescing |
.. | 1..10 | Exclusive range |
..= | 1..=10 | Inclusive range |
=> | pat => expr | Match arm |
-> | fn() -> T | Return type |
:: | Type::method | Path separator |
. | obj.field | Field access |
& | &value | Reference |
* | *ptr | Dereference |
Delimiters
| Symbol | Description |
|---|
{ } | Block or struct literal |
[ ] | Array literal or indexing |
( ) | Grouping or tuple |
< > | Generic parameters |
; | Statement terminator |
: | Type annotation |
, | Separator |