fromEquals<A> function

Eq<A> fromEquals<A>(
  1. bool equals(
    1. A x,
    2. A y
    )
)

Creates an Eq from a given equality checking function.

Example:

void main() {
  // Define an Eq for comparing integers based on divisibility by 5
  final eqDivisibleBy5 = fromEquals<int>((x, y) => x % 5 == y % 5);

  print(eqDivisibleBy5.equals(15, 5)); // Output: true (Both are divisible by 5)
  print(eqDivisibleBy5.equals(10, 6)); // Output: false (10 % 5 is 0, while 6 % 5 is 1)
}

Implementation

Eq<A> fromEquals<A>(bool Function(A x, A y) equals) {
  return _Eq(equals);
}