Kotlin / kotlin-style-guide

Work-in-progress notes for the Kotlin style guide
288 stars 14 forks source link

Non-local returns #19

Open yole opened 8 years ago

yole commented 8 years ago

Avoid using multiple labeled returns in a lambda. Consider restructuring the lambda so that it will have a single exit point. If that's not possible or not clear enough, convert the lambda into an anonymous function.

voddan commented 8 years ago

Do not use a labeled return for the last statement in a lambda:

//Bad
CachedThreadPool.submit { return@submit 239 }