Last active
November 27, 2019 20:32
-
-
Save chao2zhang/dace2f3972d8ea9d0c1a56bc5d1b1cd7 to your computer and use it in GitHub Desktop.
JavaCode consuming Kotlin 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
// KotlinApp.kt | |
typealias KotlinFunction = (Int) -> Boolean | |
fun invokeKotlinFunction(id: Int, f: KotlinFunction) = f(id) | |
// JavaApp.java | |
private void useKotlinFunction() | |
Function1<Integer, Boolean> kotlinFunc = id -> id % 2 == 0; | |
KotlinAppKt.invokeKotlinFunction(3, id -> id % 2 == 0); | |
KotlinAppKt.invokeKotlinFunction(4, this::isEven); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment