Add rmul to distance and speeds, so that reversed operands work

This commit is contained in:
Magnus Wolffelt 2021-08-16 10:03:40 +02:00
parent 08365bcbda
commit 8f5b6f58d1

View File

@ -62,6 +62,8 @@ class Distance:
def __mul__(self, other: Union[float, int]) -> Distance:
return meters(self.meters * other)
__rmul__ = __mul__
def __truediv__(self, other: Union[float, int]) -> Distance:
return meters(self.meters / other)
@ -147,6 +149,8 @@ class Speed:
def __mul__(self, other: Union[float, int]) -> Speed:
return kph(self.kph * other)
__rmul__ = __mul__
def __truediv__(self, other: Union[float, int]) -> Speed:
return kph(self.kph / other)