Skip to content

Instantly share code, notes, and snippets.

@arifvn
Last active November 15, 2020 20:10
Show Gist options
  • Save arifvn/ef0c35a091343cea754f2181d4737d04 to your computer and use it in GitHub Desktop.
Save arifvn/ef0c35a091343cea754f2181d4737d04 to your computer and use it in GitHub Desktop.
// declaration
inline fun inlineFunction(callback: () -> Unit) {
println("before callback")
callback()
println("after callback")
}
// calling function
btnPrintMessage.setOnClickListener(){
inlineFunction(){
println("Inline function has been called")
}
}
// calling function will be treated in java like this
btnPrintMessage.setOnClickListener(){
@override
void OnClick(View v){
println("before callback")
// this is callback body in nonInlineFunction
println("Inline function has been called")
println("after callback")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment