Operations

We already saw the assignment operation, which gives a new value to a variable using the = operator. Let's take a look at few more operators:

Operator Name Description Example
= Assignment Assigns the value to a variable a = 10
:= Declaration and assignment Declares a variables and assigns a value to it a := 0
== Equals Compares two variables, returns a Boolean if they are the same a == b
!= Not equals Compares two variables, returns a Boolean if they are different a != b
+ Plus Sum between the same numerical type a + b
- Minus Difference between the same numerical type a - b
* Times Multiplication between the same numerical type a * b
/ Divided Division between the same numerical type a / b
% Modulo Remainder after division of the same numerical type a % b
& AND Bit-wise AND a & b
&^ Bit clear Bit clear a &^ b
<< Left shift Bit shift to the left a << b
>> Right shift Bit shift to the right a >> b
&& AND Boolean AND a && b
|| OR Boolean OR a || b
! NOT Boolean NOT !a
<- Receive Receive from a channel <-a
-> Send Send to a channel a <- b
& Reference Returns the pointer to a variable &a
* Dereference Returns the content of a pointer *a