Skip to content

Commit 6b6c553

Browse files
igor-petrukqwandor
andauthored
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>
1 parent 20e8316 commit 6b6c553

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/control-flow/if-expressions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ fn main() {
2525
};
2626
}
2727
```
28+
29+
<details>
30+
31+
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.
32+
33+
</details>

0 commit comments

Comments
 (0)