operator - method

List<num> operator -(
  1. List<num> other
)

Returns a new list consisting of the difference of the elements of this and other.

Implementation

List<num> operator -(List<num> other) {
  mustHaveSameLength(other, operatorSymbol: '-');
  if (this is List<int> && other is List<int>) {
    return List<int>.generate(length, (i) => (this[i] as int) - other[i]);
  }
  if (this is List<double>) {
    return List<double>.generate(
      length,
      (i) => this[i].toDouble() - other[i],
    );
  }
  if (other is List<double>) {
    return List<double>.generate(length, (i) => this[i] - other[i]);
  }
  return List<num>.generate(length, (i) => this[i] - other[i]);
}