better hash value from enumerables; fix #2906

This commit is contained in:
Yukihiro "Matz" Matsumoto
2015-08-03 13:24:04 +09:00
parent 52a9712c26
commit 95412aeb50
+4 -1
View File
@@ -402,8 +402,11 @@ module Enumerable
# redefine #hash 15.3.1.3.15
def hash
h = 12347
i = 0
self.each do |e|
h ^= e.hash
n = e.hash << (i % 16)
h ^= n
i += 1
end
h
end