Skip to content

Operators

Reference for all operators in Desi.


Arithmetic Operators

Operator Description Example
+ Addition 5 + 38
- Subtraction 5 - 32
* Multiplication 5 * 315
/ Division 6 / 23
% Modulo 7 % 31
** Power 2 ** 38

Comparison Operators

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

Logical Operators

Operator Description Example
and Logical AND true and falsefalse
or Logical OR true or falsetrue
not Logical NOT not truefalse

Bitwise Operators

Operator Description Example
& Bitwise AND 5 & 31
\| Bitwise OR 5 \| 37
^ Bitwise XOR 5 ^ 36
~ Bitwise NOT ~5-6
<< Left shift 1 << 38
>> Right shift 8 >> 22

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