Is it possible to somehow call function in differe...
# getting-started
z
Is it possible to somehow call function in different interfaces to combine all results? How to implement
toMetadata
to call all
buildMetadata
function and merge lists?
Copy code
interface Meta {
    fun buildMetadata(): List<String>
}

interface FeatA : Meta {
   override fun buildMetadata(): List<String> = listOf("A")
}

interface FeatB : Meta {
   override fun buildMetadata(): List<String> = listOf("B")
}

class ObjC: FeatA, FeatB {
    override fun buildMetadata(): List<String> = emptyList()
    fun toMetadata(): List<String> // //What to do here to combine all lists (metadata) from interfaces?
}

fun main() {
    val c = ObjC()
    println(c.toMetadata()) // expecting ["A", "B"]
}
e
https://kotlinlang.org/docs/inheritance.html#overriding-rules
Copy code
super<FeatA>.buildMetadata() + super<FeatB>.buildMetadata()
❤️ 1