I have an interface with two methods:
interface Human {
fun talk()
fun think()
}
I want to pass an anonymous instance of this interface into a method.
How do I do this?
I have an interface with two methods:
interface Human {
fun talk()
fun think()
}
I want to pass an anonymous instance of this interface into a method.
How do I do this?
If foo
looks like this:
fun foo(human: Human) {
// ...
}
You can invoke it like this, using an object expression:
foo(object: Human {
override fun think() {
// ...
}
override fun talk() {
//...
}
})