Skip to content

Commit 7b6880e

Browse files
authored
update: returns feedback (#4920)
1 parent e56cd02 commit 7b6880e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

docs/topics/returns.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ fun main() {
111111

112112
Note that the use of local returns in the previous three examples is similar to the use of `continue` in regular loops.
113113

114-
There is no direct equivalent for `break`, but it can be simulated by adding another nesting lambda and non-locally returning from it:
114+
There is no direct equivalent for `break`, but it can be simulated by adding an outer `run` lambda and non-locally
115+
returning from it:
115116

116117
```kotlin
117118
//sampleStart
@@ -132,6 +133,8 @@ fun main() {
132133
```
133134
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
134135

136+
The non-local return here is possible since the nested `forEach()` lambda acts as an [inline function](inline-functions.md).
137+
135138
When returning a value, the parser gives preference to the qualified return:
136139

137140
```kotlin

0 commit comments

Comments
 (0)