From 38831b861960cd3530eacf941197dea1e58ea35a Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Tue, 16 Apr 2024 14:30:19 -0600 Subject: [PATCH] Chapter 3: Clarify `return` vs. `break`. --- src/ch03-05-control-flow.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ch03-05-control-flow.md b/src/ch03-05-control-flow.md index 34b8372f34..ac416660d9 100644 --- a/src/ch03-05-control-flow.md +++ b/src/ch03-05-control-flow.md @@ -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