Skip to content

Instantly share code, notes, and snippets.

@jonnyzzz
Created October 12, 2018 20:34
Show Gist options
  • Save jonnyzzz/ad8e2726f7522e86b5a58b0d913a2593 to your computer and use it in GitHub Desktop.
Save jonnyzzz/ad8e2726f7522e86b5a58b0d913a2593 to your computer and use it in GitHub Desktop.
fun callWithLambda(x: () -> Unit) = x()
inline fun callW(crossinline x: () -> Unit) {
callWithLambda {
x()
x()
}
}
fun main(args: Array<String>) {
callW { println("ddds") }
//the callW is inlined.
//the x();x() is also inlined into the lambda, having
//public final void invoke() {
// String var1 = "ddds";
// System.out.println(var1);
// var1 = "ddds";
// System.out.println(var1);
// }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment