lib/hpsqrt.rb in hpsqrt-1.6.0 vs lib/hpsqrt.rb in hpsqrt-1.7.0

- old
+ new

@@ -21,10 +21,11 @@ def initialize(terms) @terms = terms.freeze @cache = {} freeze end + private :initialize def -@ terms = @terms.map{|t,c| [t, -c]}.to_h self.class.new(terms) end @@ -117,12 +118,14 @@ super.==(other) end end def <=>(other) - if self==other + if !(Numeric===other) + nil + elsif self==other 0 - elsif !self.real? || !other.real? + elsif !self.real? || !other.imag.zero? nil else self.real <=> other.real end end