Arnau Díaz
10/22/2019, 8:13 AMabstract class ParentObject(val id: Int)
class ChildObject(id: Int, val value: String) : ParentObject(id)
With adt/sealed class it doesn't compile:
sealed class ParentObject(val id: Int)
data class ChildObject(id: Int, val value: String) : ParentObject(id)
Is there any way to get it working in Kotlin? I want the benefits of the data classes but there are some fields that are common for all my subtypes.spand
10/22/2019, 8:15 AMsealed class ParentObject {
abstract val id: Int
}
data class ChildObject(override val id: Int, val value: String) : ParentObject()
Arnau Díaz
10/22/2019, 8:18 AM