Last active
November 15, 2020 20:10
-
-
Save arifvn/ef0c35a091343cea754f2181d4737d04 to your computer and use it in GitHub Desktop.
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
// 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