Skip to content

Instantly share code, notes, and snippets.

@erokhins
Created April 21, 2017 14:25
Show Gist options
  • Save erokhins/1517a0bd196286bc57605d14d078c5bd to your computer and use it in GitHub Desktop.
Save erokhins/1517a0bd196286bc57605d14d078c5bd to your computer and use it in GitHub Desktop.
// FILE: 1.kt
package p3
class A {
fun<T> inTransaction(block: (tran: String) -> T): T {
println("Function 1")
return block("")
}
fun inTransaction(block: (tran: String) -> Unit) {
println("Function 2")
}
}
// FILE: B.java
package p3;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
public class B {
public static void main(String[] args) {
A a = new A();
Function1<String, Integer> fInt = x -> 4;
a.inTransaction(fInt);
Function1<String, Unit> fString = x -> Unit.INSTANCE;
a.inTransaction(fString);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment