mirror of https://github.com/rust-lang/book
Merge pull request #3889 from rust-lang/chriskrycho/ch-3-break-vs-return
Chapter 3: Clarify `return` vs. `break`.
This commit is contained in:
commit
7f2149c356
|
@ -250,6 +250,9 @@ and then check whether the `counter` is equal to `10`. When it is, we use the
|
|||
semicolon to end the statement that assigns the value to `result`. Finally, we
|
||||
print the value in `result`, which in this case is `20`.
|
||||
|
||||
You can also `return` from inside a loop. While `break` only exits the current
|
||||
loop, `return` always exits the current function.
|
||||
|
||||
#### Loop Labels to Disambiguate Between Multiple Loops
|
||||
|
||||
If you have loops within loops, `break` and `continue` apply to the innermost
|
||||
|
|
Loading…
Reference in New Issue