I was reading someone's code for some thing and fo...
# announcements
o
I was reading someone's code for some thing and found this strange class definition
Copy code
class Usage(from: List<UsageArgument> = listOf(), val runsAt: List<RunAt> = listOf()) : List<UsageArgument> by from {
    override fun toString(): String {
        val result = joinToString(" ") { it.format() }

        return if (result.isBlank()) "none" else result
    }
}
can anyone explain this to me? especially the parameters of the class def and the ending "by from". what does it mean? the use case is like a list or something i suppose?
c
strange?
f
c
delegation is a hard topic
to wrap your head around it , look at delegation pattern before hand.
r
off-topic: i remembered KotlinConf 2018 Closing Panel someone pointed delegation as their most hateful feature. and in ktconf 2019 Andrej says delegation is what he want to redesign most, IIRC.