Skip to content

Commit

Permalink
Chapter 3: Clarify return vs. break.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskrycho committed Apr 16, 2024
1 parent e58f1ca commit 38831b8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ch03-05-control-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 38831b8

Please sign in to comment.