compareTo method

  1. @override
int compareTo(
  1. dynamic n2
)
override

Compares this Number to another Number by comparing values. n2 is expected to be a num or Number. If it is not it will be considered to have a value of 0.

Implementation

@override
int compareTo(dynamic n2) {
  if (n2 is Number) return Comparable.compare(toDouble(), n2.toDouble());
  if (n2 is num) return Comparable.compare(toDouble(), n2);

  // If n2 is not a num or Number, treat it as a zero
  return Comparable.compare(toDouble(), 0);
}