Last active
November 26, 2019 06:59
-
-
Save chao2zhang/b5750cc0fb3eb52a694675fe0f8ec83b to your computer and use it in GitHub Desktop.
KotlinApp.kt : Kotlin -> Kotlin
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
fun invokeKotlinInterface(id: Int, i: KotlinInterface) = i.apply(id) | |
fun useKotlinInterface() { | |
val kotlinInterface = object : KotlinInterface { | |
override fun apply(id: Int) = id % 2 == 0 | |
} | |
invokeKotlinInterface(3, object : KotlinInterface { | |
override fun apply(id: Int) = id % 2 == 0 | |
}) | |
invokeKotlinInterface(4, object : KotlinInterface { | |
override fun apply(id: Int) = isEven(id) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment