From 40776d964d3819bf3c548329e01fb3f079a8fbb1 Mon Sep 17 00:00:00 2001 From: Rory O'Connell <19547+RoryO@users.noreply.github.com> Date: Sat, 21 Jun 2025 15:50:32 -0700 Subject: [PATCH] Clarify break statement when used with a conditional --- content/docs/overview.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/content/docs/overview.md b/content/docs/overview.md index d375d476..f2ef8792 100644 --- a/content/docs/overview.md +++ b/content/docs/overview.md @@ -639,7 +639,7 @@ See the [Conditional compilation section](#when-statements) for examples of buil ### Branch statements #### `break` statement -A for loop or a switch statement can be left prematurely with a `break` statement. It leaves the innermost construct, unless a label of a construct is given: +A for loop, conditional, or a switch statement can be left prematurely with a `break` statement. It leaves the innermost construct, unless a label of a construct is given: ```odin for cond { switch { @@ -658,6 +658,13 @@ loop: for cond1 { } } +outer: if cond { + ok := check_something() + if !ok { + break outer // label names are required with conditionals + } +} + exit: { if true { break exit // works with labeled blocks too