tryForType<T> static method

EqualityComparer<T>? tryForType<T>()

Returns the default EqualityComparer that has been registered for type T.

The returned EqualityComparer will be the type registered to T for use as the comparer when the comparer parameter in various LINQ methods is omitted. The EqualityComparer will be one of the built-in default comparers (for dynamic, num, int, double, String, Duration, or BigInt) or will be a comparer that has been registered via a call to EqualityComparer.registerEqualityComparer.

If no registered comparer can be found, this method returns null.

Implementation

static EqualityComparer<T>? tryForType<T>() {
  if (_registeredEqualityComparers.containsKey(T)) {
    return _registeredEqualityComparers[T] as EqualityComparer<T>;
  }
  return null;
}