Slide 45
Slide 45 text
Pattern Matching
1. a = 1
2. 1 = a
3. 2 = a # ** (MatchError) no match of right hand side value: 1
4. {a,b} = {1,2} # a=1, b=2
5. {a,2} = {1,2} # a=1
6. {a,3} = {1,2} # ** (MatchError) ...
7. {a,_} = {1,2} # a=1
8. [head | tail] = [1,2,3] # head=1, tail=[1,2]
9. [a,b,c | _] = [1,2,3] # a=1, b=2, c=3
10. %{name: name} = %{name: "Jon", age: 10} # name="Jon"
11. {:ok, result} = some_function(args)