operator + method

  1. @override
i4 operator +(
  1. dynamic other
)
override

Adds other to this number.

If the other number is double, the value is truncated after addition

Returns i4

Implementation

@override
i4 operator +(dynamic other) {
  if (other is integer) {
    return i4(value + other.value);
  } else if (other is int) {
    return i4(value + other);
  } else if (other is double) {
    return i4((value + other).truncate());
  } else {
    throw Exception('Invalid type for operand: ${other.runtimeType}');
  }
}