Skip to content

Operators

Reference for all operators in Desi.


Arithmetic Operators

Operator Description Example
+ Addition 5 + 3 → 8
- Subtraction 5 - 3 → 2
* Multiplication 5 * 3 → 15
/ Division 6 / 2 → 3
% Modulo 7 % 3 → 1
** Power 2 ** 3 → 8

Comparison Operators

Operator Description Example
== Equal 5 == 5 → true
!= Not equal 5 != 3 → true
< Less than 3 < 5 → true
> Greater than 5 > 3 → true
<= Less or equal 3 <= 3 → true
>= Greater or equal 5 >= 5 → true

Logical Operators

Operator Description Example
and Logical AND true and false → false
or Logical OR true or false → true
not Logical NOT not true → false

Bitwise Operators

Operator Description Example
& Bitwise AND 5 & 3 → 1
\| Bitwise OR 5 \| 3 → 7
^ Bitwise XOR 5 ^ 3 → 6
~ Bitwise NOT ~5 → -6
<< Left shift 1 << 3 → 8
>> Right shift 8 >> 2 → 2

Assignment Operators

Operator Description Example
= Assign x = 5

String Operators

Operator Description Example
+ Concatenation "Hello" + " World"

Other Operators

Operator Description Example
? Try/unwrap result?
\|> Pipe x \|> f \|> g