Created
          January 8, 2019 01:57 
        
      - 
      
- 
        Save Tombarr/83b63976bbd77c9d295ca667ba6f0197 to your computer and use it in GitHub Desktop. 
    Basic Elixir pattern matching
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # is it assignment? | |
| all_systems = :go | |
| # not quite | |
| :go = all_systems | |
| # alas age is but a number | |
| tom = %{name: "Tom", age: 25} | |
| %{age: num} = tom # 25 | |
| # there's no truth in matches | |
| 1 = 1 # 1 | |
| 1 + 1 = 2 # CompileError | |
| 1 + 1 = 2 # MatchError | |
| # except when you find your one, true match | |
| [the_one | everything_else] = [true, false, false] | |
| the_one = true # true | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment