Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Pattern Matching in Elixir

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Pattern Matching in Elixir

These slide cover basic pattern matching principles in Elixir. Examples include case statements, multi-clause functions, and recusrsion

Avatar for Anna Neyzberg

Anna Neyzberg

February 27, 2017
Tweet

Other Decks in Technology

Transcript

  1. • An attempt to read the file my_app.config takes place.

    • If the attempt succeeds the file content are extracted to the variable contents. • If the attempt fails an error is raised. This is because File.read returns a tuple in the form of - {:error, reason}
  2. In Conclusion….. •In elixir the “=“ sign does not mean

    set this variable to something else • New initialized variables are bound to the term on the right hand side •Multi-clause Functions are functions that have multiple definitions and the same arity.
  3. Thank you! Twitter: @Aneyzb Email: anna@carbonfive.com Credits: • https://quickleft.com/blog/pattern-matching-elixir/ •

    Juric, Sasa. Elixir In Action. Shelter Island: Maning Publishing, 2015 Resource: elixirbridge.org