Skip to content

Instantly share code, notes, and snippets.

@renaudcerrato
Last active March 9, 2019 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renaudcerrato/b5b42b2f525082a51518191b283f3e3d to your computer and use it in GitHub Desktop.
Save renaudcerrato/b5b42b2f525082a51518191b283f3e3d to your computer and use it in GitHub Desktop.
Kotlin Inline Function
inline fun greeter(action: () -> Unit) {
try {
println("Hello!")
action()
}finally{
println("Goodbye!")
}
}
greeter {
println("How are you?")
}
// directly expands to:
try {
println("Hello!")
println("How are you?")
}finally{
println("Goodbye!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment