You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/elixir/pages/patterns-and-guards.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ This page describes the semantics of patterns and guards, where they are all all
6
6
7
7
## Patterns
8
8
9
-
Patterns in Elixir are made of variables, literals, and data-structure specific syntax. One of the most used constructs to perform pattern matching is the match operator (`=`):
9
+
Patterns in Elixir are made of variables, literals, and data-structure specific syntax. One of the most used constructs to perform pattern matching is the match operator ([`=`](`=/2`)):
10
10
11
11
```iex
12
12
iex> x = 1
@@ -156,7 +156,7 @@ iex> [head | tail] = []
156
156
** (MatchError) no match of right hand side value: []
157
157
```
158
158
159
-
Given charlists are represented as a list of integers, one can also perform prefix matches on charlists using the list concatenation operator (`++`):
159
+
Given charlists are represented as a list of integers, one can also perform prefix matches on charlists using the list concatenation operator ([`++`](`++/2`)):
160
160
161
161
```elixir
162
162
iex>'hello '++ world ='hello world'
@@ -207,7 +207,7 @@ Finally, note map keys in patterns must always be literals or previously bound v
207
207
208
208
### Binaries
209
209
210
-
Binaries may appear in patterns using the double less-than/greater-than syntax (`<<>>`). A binary in a pattern can match multiple segments at the same, each with different type, size, and unit:
210
+
Binaries may appear in patterns using the double less-than/greater-than syntax ([`<<>>`](`<<>>/1`)). A binary in a pattern can match multiple segments at the same, each with different type, size, and unit:
See the documentation for `<<>>` for a complete definition of pattern matching for binaries.
219
+
See the documentation for [`<<>>`](`<<>>/1`) for a complete definition of pattern matching for binaries.
220
220
221
-
Finally, remember that strings in Elixir are UTF-8 encoded binaries. This means that, similar to charlists, prefix matches on strings are also possible with the binary concatenation operator (`<>`):
221
+
Finally, remember that strings in Elixir are UTF-8 encoded binaries. This means that, similar to charlists, prefix matches on strings are also possible with the binary concatenation operator ([`<>`](`<>/2`)):
222
222
223
223
```elixir
224
224
iex>"hello "<> world ="hello world"
@@ -380,7 +380,7 @@ Check.empty?({})
380
380
381
381
## Where patterns and guards can be used
382
382
383
-
In the examples above, we have used the match operator (`=`) and function clauses to showcase patterns and guards respectively. Here is the list of the built-in constructs in Elixir that support patterns and guards.
383
+
In the examples above, we have used the match operator ([`=`](`=/2`)) and function clauses to showcase patterns and guards respectively. Here is the list of the built-in constructs in Elixir that support patterns and guards.
384
384
385
385
*`match?/2`:
386
386
@@ -428,7 +428,7 @@ In the examples above, we have used the match operator (`=`) and function clause
428
428
429
429
* custom guards can also be defined with `defguard/1` and `defguardp/1`. A custom guard can only be defined based on existing guards.
430
430
431
-
Note that the match operator (`=`) does *not* support guards:
431
+
Note that the match operator ([`=`](`=/2`)) does *not* support guards:
0 commit comments