I’m creating some exercises for a small Kotlin cou...
# random
m
I’m creating some exercises for a small Kotlin course for my company. I’m trying to create a fun exercise about sealed classes. I was thinking about modelling a state machine, but I just can’t come up with a fun example for it right now. Do anyone have an idea? 🙂 I’m thinking about making something like this:
Copy code
sealed class State
class State1(val data: Int) : State()
class State2(val otherData: Int) : State()
object State3 : State()

sealed class Action
class Action1(val actionData: Int) : Action()
object Action2 : Action()

fun State.nextState(action: Action): State = TODO("Write this function")
k
Maybe something that parses a simple regex like
a*(b|c)*
?