EitherOrd<A, B> constructor

EitherOrd<A, B>(
  1. Ord<A> leftOrd,
  2. Ord<B> rightOrd
)

Implementation

EitherOrd(this.leftOrd, this.rightOrd)
    : super((Either<A, B> x, Either<A, B> y) {
        if (identical(x, y)) return 0;

        switch (x) {
          case Left(value: var leftXValue):
            if (y is Left<A, B>) {
              return leftOrd.compare(leftXValue, y.value);
            }
            return -1;

          case Right(value: var rightXValue):
            if (y is Right<A, B>) {
              return rightOrd.compare(rightXValue, y.value);
            }
            return 1;
        }
      });