From the course: Elixir 101: Essential Functional Programming Techniques
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
The match operator - Elixir Tutorial
From the course: Elixir 101: Essential Functional Programming Techniques
The match operator
- [Instructor] This video begins with a quick recap of the match operator before we put it to use with different data types. The match operator determines if it's left and right sides match. This means we can use the match operator to match patterns inside data structures. This is called pattern matching. Pattern matching is one of my favorite tools. In the terminal bind a value to a variable to see the match operator at work. W equals wizard. Both sides of the match operator match which means we can also write this now. Wizard equals W. This is a valid expression because wizard is the value on both the left side of the match operator and the right side of the match operator. This is pretty cool, but before we get carried away it's important to note that a variable can only be bound when it appears on the left side of the match operator. If we try the other way around we get an error like this. Lizard equals X.…