Elixir Pattern Matching Tutorial: Difference between revisions
From ElixirBlocks
(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...") |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
'''Use Pattern Matching as a Replacement for Conditional Statements''' | '''Use Pattern Matching as a Replacement for Conditional Statements''' | ||
In most programming languages conditional if/else statements are used to program | In most programming languages conditional if/else statements are used to program decision making trees. 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. | 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. | ||
Line 11: | Line 11: | ||
https://inquisitivedeveloper.com/lwm-elixir-22/ | https://inquisitivedeveloper.com/lwm-elixir-22/ | ||
https://inquisitivedeveloper.com/lwm-elixir-23/ |
Latest revision as of 02:44, 2 September 2023
Use Pattern Matching as a Replacement for Conditional Statements
In most programming languages conditional if/else statements are used to program decision making trees. 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: