OptionEq<A> class

Defines equality for instances of Option.

The equality of two Option instances depends on the equality of the values they contain (if any). For this purpose, this class requires an instance of Eq<A> for the type of the values the Option might hold.

final intEq = Eq.fromEquals((int x, int y) => x == y);
final optionEq = getEq(intEq);

expect(optionEq.equals(Some(1), Some(1)), true);
expect(optionEq.equals(Some(1), Some(2)), false);
expect(optionEq.equals(Some(1), None()), false);
expect(optionEq.equals(None(), None()), true);
Implemented types

Constructors

OptionEq(Eq<A> eq)
Constructs an instance of OptionEq.

Properties

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

Methods

equals(Option<A> x, Option<A> 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