A couple years ago when I first starting learning ...
# android
t
A couple years ago when I first starting learning Kotlin, porting an iOS Swift app, there wasn't a real comparable idiom to the Swift Enums which can capture values. I'm curious what the general approach now days for expressing something like the following Swift idiom in Kotlin?
Copy code
enum ValveRunInterval {
    case future(start:Date, plan:Plan)
    case active(interval:DateInterval, plan:Plan)
    ...
}
I could use a little abstract/two subclass triad to express this. Not sure what the rules are when combining data classes and inheritance. Is there a better/different way?
d
sealed class
?
2
plus one 4
m
Someone made a compiler plugin to convert sealed classed to Swift enums. https://medium.com/icerock/how-to-implement-swift-friendly-api-with-kotlin-multiplatform-mobile-e68521a63b6d