https://kotlinlang.org logo
#getting-started
Title
# getting-started
y

y

10/10/2023, 6:07 PM
should I prefer a
sealed interface
over a
sealed class
if possible? or is there no particular reason to choose either, when multiple interfaces are not going to be implemented?
k

Kirill Grouchnikov

10/10/2023, 6:09 PM
General preference in OOP is to code to interfaces and not to classes. What is “multiple interfaces are not going to be implemented”?
i

igor.wojda

10/10/2023, 6:16 PM
sealed interface. Common scanty is to use sealed interface to define a "base" state and then used data classes and data objects to extend this interface