diff --git a/lib/vector.rb b/lib/vector.rb index 24048cd..f35382a 100644 --- a/lib/vector.rb +++ b/lib/vector.rb @@ -39,8 +39,12 @@ def *(scalar) Vector.new(x * scalar, y * scalar) end - def coerce(scalar) - [self, scalar] + def coerce(scalar) + if scalar.is_a?(Numeric) + [self, scalar] + else + raise ArgumentError, "Cannot coerce #{scalar.inspect}" + end end end end \ No newline at end of file