What is the advantage of have "trait extending class" in kotlin?


#1

Hi All,

I realized that in Kotlin, a trait can extend from a class.

open class FooClass

trait FooTrait : FooClass


Is there any particular use case that can benefit from above feature?


#2

Yes, in such a trait you can call methods of this class, i.e. you can define functionality that can be "mixed in" within a particular class hierarhy. I'm not sure this feature has very many use cases, though. We may consider dropping it.