operator == method

  1. @override
bool operator ==(
  1. Object other
)
override

Test whether this value is numerically equal to other.

If both operands are decimals, they are equal if they have the same representation, except that:

  • zero and minus zero (0.0 and -0.0) are considered equal. They both have the numerical value zero.
  • NaN is not equal to anything, including NaN. If either operand is NaN, the result is always false.

If one operand is a decimal and the other is an int, they are equal if the decimal has an integer value (finite with no fractional part) and identical(decimalValue.toInt(), intValue) is true.

If both operands are integers, they are equal if they have the same value.

Returns false if other is not a num.

Implementation

@override
bool operator ==(Object other) {
  if (other is Decimal) {
    return (other.isInteger && identical(other.toInteger().value, value));
  }
  return other is Integer && value == other.value;
}