reactormonk
07/08/2022, 9:56 AMCardStatus.Companion.Present
instead of CardStatus.Present
here?
sealed class CardStatus(val value: Int) {
companion object {
fun fromInt(int: Int): CardStatus {
return when(int) {
255 -> PowerSavingMode
3 -> Powered
2 -> Present
1 -> Absent
else -> Error(int)
}
}
object PowerSavingMode: CardStatus(255)
object Powered: CardStatus(3)
object Present: CardStatus(2)
object Absent: CardStatus(1)
data class Error(val errorValue: Int): CardStatus(errorValue)
}
}
hfhbd
07/08/2022, 9:59 AMreactormonk
07/08/2022, 10:00 AMKlitos Kyriacou
07/08/2022, 10:33 AMinner
keyword. Similarly with nested objects (in fact, I'm not sure what an "inner object" would even mean, if it were allowed).reactormonk
07/08/2022, 12:19 PM