Last active
March 9, 2019 06:52
-
-
Save renaudcerrato/b5b42b2f525082a51518191b283f3e3d to your computer and use it in GitHub Desktop.
Kotlin Inline Function
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 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