Operators
Elixir comes with a set of basic operators that largely work the way that you would expect. Most operators will feel similar to the operators you use in Ruby, and you’ll be right at home. But a few of these operators will behave much differently than similar operators in Ruby.
We’ll cover the most commonly used Elixir operators, and you’ll see the important differences that a few of these operators have compared to Ruby.
- Assignment (Match)
-
= is called the match operator. You can use this as you would in Ruby (my_var = 1), but it does much more than just assignment.
It’s also used for pattern matching and complex structural comparisons ([a, b] = [1, 2]). Pattern matching is one of the most important parts of Elixir’s syntax, so Chapter ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access