Title
s

shiraji

01/26/2017, 8:09 AM
Does kotlin accept Class Delegation using
object
? The following code compile.
interface I {
    fun foo()
}

object O : I {
    override fun foo() {
        println("Foo!!!")
    }
}

class C : I by O

fun main(args: Array<String>) {
    C().foo() // Foo!!!
}
r

robin

01/26/2017, 8:11 AM
shiraji: I don't know why that shouldn't work. An object is just a a Singleton that behaves just like a regular class instance otherwise.
s

shiraji

01/26/2017, 8:14 AM
@robin I just have never seen this before.
This is totally expected behavior, then