Created
April 21, 2017 14:25
-
-
Save erokhins/1517a0bd196286bc57605d14d078c5bd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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