compareTo method

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

Compares this Quantity to q2 by comparing MKS values. The Quantities need not have the same dimensions.

Returns a negative integer, zero, or a positive integer as this Quantity is less than, equal to, or greater than q2.

Implementation

@override
int compareTo(dynamic q2) {
  if (q2 is! Quantity) {
    throw const QuantityException('A Quantity cannot be compared to anything besides another Quantity');
  }
  return valueSI.compareTo(q2.valueSI);
}