Skip to content
Permalink
Browse files

Merge pull request #708 from kostya/hash_cmp

Hash compares
  • Loading branch information
alex committed May 17, 2013
2 parents 4b12dbf + cd9064e commit 5b94f7c42cb0192a8628797e3f56e69f07d29058
@@ -60,21 +60,27 @@ def to_a
end

def ==(other)
if self.equal?(other)
return true
end
if !other.kind_of?(Hash)
return false
end
if self.size != other.size
return false
return true if self.equal?(other)
return false unless other.kind_of?(Hash)
return false unless self.size == other.size
Thread.current.recursion_guard(:hash_compare, self) do
self.each do |key, value|
return false unless other.has_key?(key) && value == other[key]
end
end
self.each do |key, value|
if !other.has_key?(key) || other[key] != value
return false
true
end

def eql?(other)
return true if self.equal?(other)
return false unless other.kind_of?(Hash)
return false unless self.size == other.size
Thread.current.recursion_guard(:hash_eql, self) do
self.each do |key, value|
return false unless other.has_key?(key) && value.eql?(other[key])
end
end
return true
true
end

def merge!(other, &block)

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 5b94f7c

Please sign in to comment.