Elixir Pattern Matching Tutorial

From ElixirBlocks
Revision as of 02:26, 2 September 2023 by Admin (talk | contribs) (Created page with " '''Use Pattern Matching as a Replacement for Conditional Statements''' In most programming languages conditional if/else statements are used to program branched actions in a program. In Elixir, it is considered "idiomatic" to use pattern patching in place of conditional statements. If you are learning Elixir after learning another programming language, you may be tempted to use if/else conditional statements. In Elixir, resist this temptation and instead default to...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Use Pattern Matching as a Replacement for Conditional Statements

In most programming languages conditional if/else statements are used to program branched actions in a program. In Elixir, it is considered "idiomatic" to use pattern patching in place of conditional statements.

If you are learning Elixir after learning another programming language, you may be tempted to use if/else conditional statements. In Elixir, resist this temptation and instead default to using pattern matching.


The most comprehensive tutorial I've found on the topic is here:

https://inquisitivedeveloper.com/lwm-elixir-22/