Hi,
I’m wondering what is the cleanest way to inherit arguments in a constructor of a sealed class
sealed class Person(val id: Long, val name: String) {
class Developer(id: Long, name: String, val favoriteLanguage: String): Person(id, name)
class Painter(id: Long, name: String, val paintingsSold: Long): Person(id, name)
}
Is there a way to avoid repeating the args in each case of the class?
Ideally, I would like to write this
sealed class Person(val id: Long, val name: String) {
class Developer(val favoriteLanguage: String): Person
class Painter(val paintingsSold: Long): Person
}
And then create instances with the arguments from Person either before or after the arguments of Developer and Painter.