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);
Implemented types

Constructors

EitherEq(Eq<A> leftEq, Eq<B> rightEq)
Constructs an instance of EitherEq.

Properties

hashCode int
The hash code for this object.
read-onlyinherited
leftEq Eq<A>
The Eq instance for the type of the values the Either might hold.
final
rightEq Eq<B>
final
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

Methods

equals(Either<A, B> x, Either<A, B> y) bool
Checks if x and y are 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