1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-03-21 22:49:44 +02:00

Update if-expressions.md (#236)

* Update if-expressions.md

Adding a note about types of `if` branch blocks.

* Fix typo and simplify.

Co-authored-by: Andrew Walbran <qwandor@google.com>
This commit is contained in:
Igor Petruk 2023-01-23 12:44:20 +00:00 committed by GitHub
parent 20e83166f4
commit 6b6c553789
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,3 +25,9 @@ fn main() {
};
}
```
<details>
Because `if` is an expression and must have a particular type, both of its branch blocks must have the same type. Consider showing what happens if you add `;` after `x / 2` in the second example.
</details>