Skip to content

Instantly share code, notes, and snippets.

@shahsurajk
Created July 17, 2019 14:41
Show Gist options
  • Save shahsurajk/8cca875560f2a66412b609aa7aa4cbe2 to your computer and use it in GitHub Desktop.
Save shahsurajk/8cca875560f2a66412b609aa7aa4cbe2 to your computer and use it in GitHub Desktop.
Cross Inlined And Inlined Lambdas
inline fun mixedLambdaHolder(crossinline nonLocalReturnBlockedLambda: () -> Unit, normalLambda: () -> Unit){
nonLocalReturnBlockedLambda.invoke()
normalLambda.invoke()
}
fun main(){
mixedLambdaHolder(nonLocalReturnBlockedLambda = {
return@mixedLambdaHolder // only this can be use, this only returns the lambda and not the main function
return // this throws a compiling error, saying 'return' is not allowed here.
}, normalLambda = {
return@mixedLambdaHolder // this can return nboth main and only the lambda as well
return
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment