Skip to content

Commit 5398508

Browse files
jayjunJosé Valim
authored andcommitted
Improve the failing guards guide (#6312)
1 parent 413d833 commit 5398508

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/elixir/pages/Guards.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ Other constructs are `for`, `with`, `try`/`rescue`/`catch`/`else`/, and the `mat
104104

105105
## Failing guards
106106

107-
Errors in guards do not result in a runtime error, but in the erroring guard fail. For example, the `length/1` function only works with lists, and if we use it on anything else it fails:
107+
Errors in guards do not result in runtime errors, but in guards failing. For example, the `length/1` function only works with lists. If we use it with anything else, a runtime error is raised:
108108

109109
```elixir
110110
iex> length("hello")
111111
** (ArgumentError) argument error
112112
```
113113

114-
However, when used in guards, it simply makes the corresponding clause fail (i.e., not match):
114+
However, when used in guards, the corresponding clause simply fails to match:
115115

116116
```elixir
117117
iex> case "hello" do
@@ -123,7 +123,7 @@ iex> case "hello" do
123123
:length_failed
124124
```
125125

126-
In many cases, we can take advantage of this: in the code above, for example, we can use `length/1` to both check that the given thing is a list *and* check some properties of its length (instead of using `is_list(something) and length(something) > 0`).
126+
In many cases, we can take advantage of this. In the code above, we used `length/1` to both check that the given thing is a list *and* check some properties of its length (instead of using `is_list(something) and length(something) > 0`).
127127

128128
## Expressions in guard clauses
129129

0 commit comments

Comments
 (0)