diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-01-16 21:33:48 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-01-16 21:33:48 +0900 |
| commit | c7cff199dc14a7fb7a43910f885ca7fa9b2ccdfd (patch) | |
| tree | e2179909fd18539d5a03ebcf4cba06a2702e7225 /mrblib/enum.rb | |
| parent | e63c1e1d493bb97d4a299e2ab55c8aa6e46681e0 (diff) | |
| download | mruby-c7cff199dc14a7fb7a43910f885ca7fa9b2ccdfd.tar.gz mruby-c7cff199dc14a7fb7a43910f885ca7fa9b2ccdfd.zip | |
hash value of enumerable should be obtained from its elements; close #1658
Diffstat (limited to 'mrblib/enum.rb')
| -rw-r--r-- | mrblib/enum.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/mrblib/enum.rb b/mrblib/enum.rb index 0593e1f04..e6aa682dd 100644 --- a/mrblib/enum.rb +++ b/mrblib/enum.rb @@ -395,4 +395,13 @@ module Enumerable # # ISO 15.3.2.2.20 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 |
