From 6b6c553789be5d8733b54f0efc275f16d528895a Mon Sep 17 00:00:00 2001 From: Igor Petruk <ipetruk@google.com> Date: Mon, 23 Jan 2023 12:44:20 +0000 Subject: [PATCH] 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> --- src/control-flow/if-expressions.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/control-flow/if-expressions.md b/src/control-flow/if-expressions.md index 4afa2371..1c7d86ed 100644 --- a/src/control-flow/if-expressions.md +++ b/src/control-flow/if-expressions.md @@ -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>