EitherEq<A, B> class
Defines equality for instances of Either.
The equality of two Either instances depends on the equality of the values
they contain (if any). For this purpose, this class requires two instances of
Eq<A> and Eq<B> for the types of the values the Either might hold.
final intEq = Eq.fromEquals((int x, int y) => x == y);
final strEq = Eq.fromEquals((String x, String y) => x == y);
final eitherEq = getEq(intEq, strEq);
expect(eitherEq.equals(Right(1), Right(1)), true);
expect(eitherEq.equals(Right(1), Right(2)), false);
expect(eitherEq.equals(Right(1), Left("Error")), false);
expect(eitherEq.equals(Left("Error"), Left("Error")), true);
Constructors
Properties
Methods
-
equals(
Either< A, B> x, Either<A, B> y) → bool -
Checks if
xandyare equal.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited