operator * method Null safety

Point<T> operator * (
  1. num factor
)

Scale this point by factor as if it were a vector.

Important Note: This function accepts a num as its argument only so that you can scale Point<double> objects by an int factor. Because the * operator always returns the same type of Point as it is called on, passing in a double factor on a Point<int> causes a runtime error.

Implementation

Point<T> operator *(num /*T|int*/ factor) {
  return Point<T>((x * factor) as T, (y * factor) as T);
}