Skip to content

Commit

Permalink
Avoid infinite recursion in Numeric#==
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Ford committed Mar 25, 2009
1 parent d948e10 commit 518d262
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
7 changes: 6 additions & 1 deletion kernel/common/numeric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ def >=(other)

def ==(other)
return true if other.equal?(self)
!!(other == self)
if other.kind_of? Numeric
b, a = other.coerce self
a == b
else
!!(other == self)
end
end

def <=>(other)
Expand Down
1 change: 0 additions & 1 deletion spec/tags/frozen/library/rational/divmod_tags.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
fails:Rational#divmod when passed [Integer] returns the quotient as Integer and the remainder as Rational
fails:Rational#divmod when passed [Float] returns the quotient as Integer and the remainder as Float
1 change: 0 additions & 1 deletion spec/tags/frozen/library/rational/to_i_tags.txt

This file was deleted.

0 comments on commit 518d262

Please sign in to comment.