Skip to content

Commit 74d02c0

Browse files
authored
Merge pull request #294 from RoryO/master
Clarify break statement when used with a conditional
2 parents e238e3d + 40776d9 commit 74d02c0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

content/docs/overview.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ See the [Conditional compilation section](#when-statements) for examples of buil
639639

640640
### Branch statements
641641
#### `break` statement
642-
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:
642+
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:
643643
```odin
644644
for cond {
645645
switch {
@@ -658,6 +658,13 @@ loop: for cond1 {
658658
}
659659
}
660660
661+
outer: if cond {
662+
ok := check_something()
663+
if !ok {
664+
break outer // label names are required with conditionals
665+
}
666+
}
667+
661668
exit: {
662669
if true {
663670
break exit // works with labeled blocks too

0 commit comments

Comments
 (0)