Skip to content

Commit 4012e2a

Browse files
JasonXJmgeisler
andauthored
Update if.md (#2286)
The original phrasing may imply that you have to always terminated a `if` expression with `;`. But the real reason that we have to do that is because we are using it in a `let` statement here, and `let` statement has to be terminated by `;` --------- Co-authored-by: Martin Geisler <[email protected]>
1 parent 127202d commit 4012e2a

File tree

1 file changed

+3
-3
lines changed
  • src/control-flow-basics

1 file changed

+3
-3
lines changed

src/control-flow-basics/if.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ Because `if` is an expression and must have a particular type, both of its
3838
branch blocks must have the same type. Show what happens if you add `;` after
3939
`"small"` in the second example.
4040

41-
When `if` is used in an expression, the expression must have a `;` to separate
42-
it from the next statement. Remove the `;` before `println!` to see the compiler
43-
error.
41+
An `if` expression should be used in the same way as the other expressions. For
42+
example, when it is used in a `let` statement, the statement must be terminated
43+
with a `;` as well. Remove the `;` before `println!` to see the compiler error.
4444

4545
</details>

0 commit comments

Comments
 (0)