Previously, comparing a Measured::Measurable against any scalar raised an ArgumentError since it expects all arguments being compared to be of the same class. This prevented us from comparing against 0 which is a pretty good UX for this gem. Comparison with zeros of BigDecimal (i.e BigDecimal.new(0)) and Float (i.e 0.0) work as expected.
Comparing Measured::Measurable objects against other non-zero scalars still raises an error just like before.
Example:
x = Measured::Length(2, :m)
x > 0 ## evaluates to true
x < 0.0 ## evaluates to false
x == BigDecimal.new(0) ## also false
x == 2 ## ArgumentError
@Shopify/shipping
Previously, comparing a
Measured::Measurable
against any scalar raised anArgumentError
since it expects all arguments being compared to be of the same class. This prevented us from comparing against0
which is a pretty good UX for this gem. Comparison with zeros ofBigDecimal
(i.eBigDecimal.new(0)
) andFloat
(i.e0.0
) work as expected.Comparing
Measured::Measurable
objects against other non-zero scalars still raises an error just like before.Example: