semantic
semantic copied to clipboard
Comparison is not commutative
see the following:
Semantic::Version.new('1.0.0') == '1.0.0'
# true
'1.0.0' == Semantic::Version.new('1.0.0')
# false
IMO this should returns the same value. Surprising behaviors should be avoided at all cost (https://en.wikipedia.org/wiki/Principle_of_least_astonishment).
I know that on Numeric
classes there is a special method called coerce
that allow to change the comparison object without changing the base class (class of the instance on the left of the operator).
But coerce
doesn't seem to exist on String
.
So I'm not sure what could be the right approach here.