Lets imagine we have sealed class with data classes and objects inside:
sealed class CarEvent {
data class FilledFuel(val fuelAmount: Float) : CarEvent()
data class ChangedPart(val part: CarPart) : CarEvent()
object StartedEngine : CarEvent()
}
Then we have when statement reducing events:
when(event) {
is CarEvent.FilledFuel -> { do something }
is CarEvent.ChangedPart -> { do something }
CarEvent.StartedEngine -> { do something }
}
The questing is: what is the most true approach for StartedEngine object:
compare it using is operator, or without is operator (using default == inside when statement).
Is there any difference between these two?