-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Description
BigDecimal raises an error when trying to divide by a non-numeric value, even if it defines #coerce. This is inconsistent with other numeric types and with the other operators in BigDecimal, which properly coerce the value.
Trivial example that reproduces the problem:
class MyNum
def *(other)
33
end
def /(other)
99
end
def coerce(other)
[MyNum.new, self]
end
end> 10.to_d * MyNum.new
33
> 10.0 / MyNum.new
99
> 10.0.to_d / MyNum.new
MyNum can't be coerced into BigDecimal
Reactions are currently unavailable