equals method

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

Checks if x and y are equal.

Implementation

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

  // If both are None, they are equal.
  if (x is None<A> && y is None<A>) return true;

  // If both are Some, delegate to the contained Eq<A>.
  if (x is Some<A> && y is Some<A>) return eq.equals(x.value, y.value);

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