summaryrefslogtreecommitdiffhomepage
path: root/mrblib/range.rb
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-01-16 21:33:48 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-01-16 21:33:48 +0900
commitc7cff199dc14a7fb7a43910f885ca7fa9b2ccdfd (patch)
treee2179909fd18539d5a03ebcf4cba06a2702e7225 /mrblib/range.rb
parente63c1e1d493bb97d4a299e2ab55c8aa6e46681e0 (diff)
downloadmruby-c7cff199dc14a7fb7a43910f885ca7fa9b2ccdfd.tar.gz
mruby-c7cff199dc14a7fb7a43910f885ca7fa9b2ccdfd.zip
hash value of enumerable should be obtained from its elements; close #1658
Diffstat (limited to 'mrblib/range.rb')
-rw-r--r--mrblib/range.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/mrblib/range.rb b/mrblib/range.rb
index d43e3c223..7ea795078 100644
--- a/mrblib/range.rb
+++ b/mrblib/range.rb
@@ -28,6 +28,15 @@ class Range
end
self
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
##