match<T> method

T match<T>({
  1. required T event(
    1. RoadEvent value
    ),
  2. required T error(
    1. AddEventError value
    ),
})

Implementation

T match<T>({
  required T Function(RoadEvent value) event,
  required T Function(AddEventError value) error,
}) {
  return switch (this._index) {
    0 => event(this._value as RoadEvent),
    1 => error(this._value as AddEventError),
    _ => throw NativeException("Unrecognized case index ${this._index}")
  };
}