diff --git a/doc/docs.md b/doc/docs.md index 56ad15666b..05bb9ef3e2 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -947,6 +947,30 @@ stuck in an infinite loop. Here `i` doesn't need to be declared with `mut` since it's always going to be mutable by definition. +#### Labelled break & continue + +`break` and `continue` control the innermost `for` loop by default. +You can also use `break` and `continue` followed by a label name to refer to an outer `for` +loop: + +```v +outer: for i := 4;; i++ { + println(i) + for { + if i < 7 {continue outer} + else {break outer} + } +} +``` +The label must immediately precede the outer loop. +The above code prints: +``` +4 +5 +6 +7 +``` + ### Match ```v