match<T> method

T match<T>({
  1. required T speed(
    1. SimulationConstantSpeed value
    ),
  2. required T overSpeed(
    1. SimulationAutoWithOverSpeed value
    ),
})

Implementation

T match<T>({
  required T Function(SimulationConstantSpeed value) speed,
  required T Function(SimulationAutoWithOverSpeed value) overSpeed,
}) {
  return switch (this._index) {
    0 => speed(this._value as SimulationConstantSpeed),
    1 => overSpeed(this._value as SimulationAutoWithOverSpeed),
    _ => throw NativeException("Unrecognized case index ${this._index}")
  };
}