Class: Hash
- Defined in:
- lib/sane/hash_hashes.rb,
lib/sane/hash_set_operators_bug_fix.rb
Overview
see kpumuk.info/ruby-on-rails/memo-5-use-ary-uniq-method-carefully-in-ruby and test it :)
Instance Method Summary collapse
-
#-(hash) ⇒ Object
-
should not affect the original nor delete if the key + value pair aren’t equal.
-
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
Instance Method Details
#-(hash) ⇒ Object
-
should not affect the original
nor delete if the key + value pair aren’t equal
4 5 6 7 8 9 10 |
# File 'lib/sane/hash_set_operators_bug_fix.rb', line 4 def -(hash) out = self.dup hash.keys.each do |key| out.delete key if self[key] == hash[key] end out end |
#eql?(other) ⇒ Boolean
11 12 13 |
# File 'lib/sane/hash_hashes.rb', line 11 def eql?(other) self == other end |
#hash ⇒ Object
7 8 9 |
# File 'lib/sane/hash_hashes.rb', line 7 def hash inject(0) {|hash,pair| hash ^ pair.hash} end |