equals method

  1. @override
bool equals(
  1. Either<A, B> x,
  2. Either<A, B> y
)
override

Checks if x and y are equal.

Implementation

@override
bool equals(Either<A, B> x, Either<A, B> y) {
  // Short-circuit if they are identical (or both null).
  if (identical(x, y)) return true;

  // If both are Left, delegate to the contained Eq<A>.
  if (x is Left<A, B> && y is Left<A, B>) {
    return leftEq.equals(x.value, y.value);
  }

  // If both are Right, delegate to the contained Eq<B>.
  if (x is Right<A, B> && y is Right<A, B>) {
    return rightEq.equals(x.value, y.value);
  }

  // In all other cases they are not equal.
  return false;
}