Skip to content

Commit

Permalink
Fix typos in let assert concept
Browse files Browse the repository at this point in the history
* Update instructions.md to fix typo
* Update instructions.md to fix typo
* Update introduction.md for let assertion concept
* Update introduction.md for let assertion exercise
  • Loading branch information
gavinmcgimpsey authored Oct 8, 2023
1 parent 20b4082 commit d62c514
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions concepts/let-assertions/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn get_first_element_or_crash(items: List(e)) -> e {
}
```

Most the time in Gleam programs we want to handle every possible case, but in some programs such as prototypes and quick scripts we may want to focus only on the happy path and not write code for other cases. This is where Gleam's `let assert` comes in.
Most of the time in Gleam programs we want to handle every possible case, but in some programs such as prototypes and quick scripts we may want to focus only on the happy path and not write code for other cases. This is where Gleam's `let assert` comes in.

With let assertions a pattern can match only some of the possible values of a type, and if the pattern does not match a value the program will crash. Using `let assert` we can write the above function like this:

Expand All @@ -23,4 +23,4 @@ pub fn get_first_element_or_crash(items: List(e)) -> e {
}
```

Gleam libraries should never use let assertions as they can crash the program, instead they should use the `Result` type and let the application developer decide how to handle errors.
Gleam libraries should never use let assertions as they can crash the program. Instead, they should use the `Result` type and let the application developer decide how to handle errors.
4 changes: 2 additions & 2 deletions exercises/concept/spring-cleaning/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn get_first_element_or_crash(items: List(e)) -> e {
}
```

Most the time in Gleam programs we want to handle every possible case, but in some programs such as prototypes and quick scripts we may want to focus only on the happy path and not write code for other cases. This is where Gleam's `let assert` comes in.
Most of the time in Gleam programs we want to handle every possible case, but in some programs such as prototypes and quick scripts we may want to focus only on the happy path and not write code for other cases. This is where Gleam's `let assert` comes in.

With let assertions a pattern can match only some of the possible values of a type, and if the pattern does not match a value the program will crash. Using `let assert` we can write the above function like this:

Expand All @@ -25,4 +25,4 @@ pub fn get_first_element_or_crash(items: List(e)) -> e {
}
```

Gleam libraries should never use let assertions as they can crash the program, instead they should use the `Result` type and let the application developer decide how to handle errors.
Gleam libraries should never use let assertions as they can crash the program. Instead, they should use the `Result` type and let the application developer decide how to handle errors.

0 comments on commit d62c514

Please sign in to comment.