I've created an interface for the two that I have ...
# announcements
b
I've created an interface for the two that I have and I can't define the interface as sealed
d
Interfaces cannot be sealed due to JVM constrains. You need an abstract base class that you seal.
b
I can't have abstract classes for data classes, correct?
g
data class cannot be abstract, sure
d
But data classes cannot be inherited from, period.
But you can do this:
Copy code
sealed class Sealed {
    data class OptionA(val foo: String) : Sealed()
    data class OptionB(val foo: Int) : Sealed()
}
b
then use Sealed as type name for OptionA/OptionB?
d
Yes
b
ah right, that would require me to do match clauses based on the classes listed
when*
d
Yes, that's how sealed classes work
b
thank you