Created
July 17, 2019 14:41
-
-
Save shahsurajk/8cca875560f2a66412b609aa7aa4cbe2 to your computer and use it in GitHub Desktop.
Cross Inlined And Inlined Lambdas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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