Skip to content

Instantly share code, notes, and snippets.

@shahsurajk
Created July 17, 2019 15:01
Show Gist options
  • Save shahsurajk/5b9fb17180714e5b27496f5e5b1eb54c to your computer and use it in GitHub Desktop.
Save shahsurajk/5b9fb17180714e5b27496f5e5b1eb54c to your computer and use it in GitHub Desktop.
No inline demo
inline fun parameterPassedToOtherInlineFunction(lambda1: () -> Unit, noinline lambda2: () -> Boolean){
// normal invoke, this is a normal lambda.
lambda1.invoke()
// passing the lambda to another function which doesn't inline this lambda
// will throw an error if lambda2 is not marked as noinline
someNonInlinedLambdaConsumingFunction(lambda2)
}
fun someNonInlinedLambdaConsumingFunction(lambda: () -> Boolean) : Boolean{
return lambda.invoke()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment