Google News
logo
Elixir - Interview Questions
Which are the Elixir operators?
Elixir provides several operators that can be used for various operations, including arithmetic, logical, comparison, assignment, and more. Here are the most commonly used operators in Elixir:

* Arithmetic Operators :
   `+` (addition)
   `-` (subtraction)
   `*` (multiplication)
   `/` (division)
   `div` (integer division)
   `rem` (remainder)
   `**` (exponentiation)

* Comparison Operators :
   `==` (equal to)
   `!=` or `<>` (not equal to)
   `===` (strict equality, compares value and type)
   `!==` (strict inequality, compares value and type)
   `<` (less than)
   `<=` (less than or equal to)
   `>` (greater than)
   `>=` (greater than or equal to)

* Logical Operators :
    `and` (logical AND)
    `or` (logical OR)
    `not` (logical NOT)
* Bitwise Operators :
    `&&&` (bitwise AND)
    `|||` (bitwise OR)
    `^^^` (bitwise XOR)
    `<<<` (bitwise shift left)
    `>>>` (bitwise shift right)
    `~` (bitwise complement)

* Assignment Operators :
   `=` (simple assignment)
   `+=` (add and assign)
   `-=`, `*=`, `/=`, etc. (subtract and assign, multiply and assign, divide and assign, etc.)

* Pipe Operator :
   `|>` (pipe operator) : It allows chaining functions together, passing the result of one function as the first argument to the next function in the chain, enhancing code readability and composability.

* Match Operator :
   `=` (match operator) : It is used for pattern matching and variable assignment. It assigns values on the right to variables on the left, based on the matching patterns.
Advertisement