Skip to content

Instantly share code, notes, and snippets.

@chao2zhang
Last active November 26, 2019 06:59
Show Gist options
  • Save chao2zhang/b5750cc0fb3eb52a694675fe0f8ec83b to your computer and use it in GitHub Desktop.
Save chao2zhang/b5750cc0fb3eb52a694675fe0f8ec83b to your computer and use it in GitHub Desktop.
KotlinApp.kt : Kotlin -> Kotlin
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