Skip to content

Commit 8bbba57

Browse files
committed
Describe pattern matching as simpler
1 parent 968b513 commit 8bbba57

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/elixir/pages/anti-patterns/code-anti-patterns.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ iex> Graphics.plot(point_3d)
436436

437437
Overall, the usage of `map.key` and `map[:key]` encode important information about your data structure, allowing developers to be clear about their intent. See both `Map` and `Access` module documentation for more information and examples.
438438

439-
Another alternative to refactor this anti-pattern is to use pattern matching:
439+
An even simpler alternative to refactor this anti-pattern is to use pattern matching:
440440

441441
```elixir
442442
defmodule Graphics do
@@ -461,6 +461,8 @@ iex> Graphics.plot(point_3d)
461461
{5, 6, nil}
462462
```
463463

464+
Pattern-matching is specially useful when matching over multiple keys at once and also when you want to match and assert on the values of a map.
465+
464466
Another alternative is to use structs. By default, structs only support static access to its fields:
465467

466468
```elixir

0 commit comments

Comments
 (0)