hash value of enumerable should be obtained from its elements; close #1658

parent e63c1e1d
...@@ -395,4 +395,13 @@ module Enumerable ...@@ -395,4 +395,13 @@ module Enumerable
# #
# ISO 15.3.2.2.20 # ISO 15.3.2.2.20
alias to_a entries alias to_a entries
# redefine #hash 15.3.1.3.15
def hash
h = 12347
self.each do |e|
h ^= e.hash
end
h
end
end end
...@@ -28,6 +28,15 @@ class Range ...@@ -28,6 +28,15 @@ class Range
end end
self self
end end
# redefine #hash 15.3.1.3.15
def hash
h = first.hash ^ last.hash
if self.exclude_end?
h += 1
end
h
end
end end
## ##
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment