Compare commits

...

2 Commits

Author SHA1 Message Date
Veera f75b96994d
Merge e4e9ba7866 into f84626dbe0 2024-04-19 08:45:54 +08:00
Veera e4e9ba7866 Refutability: Mention `let`-`else` statement 2023-07-14 18:29:20 -04:00
1 changed files with 5 additions and 5 deletions

View File

@ -10,11 +10,11 @@ a_value` because if the value in the `a_value` variable is `None` rather than
Function parameters, `let` statements, and `for` loops can only accept
irrefutable patterns, because the program cannot do anything meaningful when
values dont match. The `if let` and `while let` expressions accept
refutable and irrefutable patterns, but the compiler warns against
irrefutable patterns because by definition theyre intended to handle possible
failure: the functionality of a conditional is in its ability to perform
differently depending on success or failure.
values dont match. The `if let` and `while let` expressions and the
`let`-`else` statement accept refutable and irrefutable patterns, but the
compiler warns against irrefutable patterns because by definition theyre intended
to handle possible failure: the functionality of a conditional is in its ability
to perform differently depending on success or failure.
In general, you shouldnt have to worry about the distinction between refutable
and irrefutable patterns; however, you do need to be familiar with the concept