kotlin-style-guide icon indicating copy to clipboard operation
kotlin-style-guide copied to clipboard

Non-local returns

Open yole opened this issue 9 years ago • 1 comments
trafficstars

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.

yole avatar Jun 01 '16 15:06 yole

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

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

voddan avatar Jun 12 '16 08:06 voddan