Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas

PatilShreyas/1WithoutFunInterface.kt Secret

Last active Jan 15, 2021
Embed
What would you like to do?
interface Predicate {
fun isTrue(): Boolean
}
fun main() {
val predicate = object: Predicate {
override fun isTrue() = 10 == (5*2)
}
println(predicate.isTrue()) // prints "true"
}
fun interface Predicate {
fun isTrue(): Boolean
}
fun main() {
val predicate = Predicate { 10 == (5*2) }
println(predicate.isTrue()) // prints "true"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment