findLabelAndCall¶
fun KtFunctionLiteral.findLabelAndCall(): Pair<Name?, KtCallExpression?>
Returns the label (explicit or the enclosing call's name) and the call that this lambda is passed to, as a pair. Either component may be null if it cannot be determined.
Example:¶
items.forEach { println(it) }
items.forEach itemLoop@ { println(it) }
val standalone = { println("done") }
For the first function literal, this returns the inferred label forEach and its call. For the explicitly labeled literal, it returns itemLoop and the call. For the literal assigned to standalone, it returns (null, null).