Class: Hash

Inherits:
Object show all
Defined in:
lib/sane/hash_hashes.rb,
lib/sane/hash_set_operators_bug_fix.rb

Overview

Instance Method Summary collapse

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

Returns:

  • (Boolean)


11
12
13
# File 'lib/sane/hash_hashes.rb', line 11

def eql?(other)
  self == other
end

#hashObject



7
8
9
# File 'lib/sane/hash_hashes.rb', line 7

def hash
  inject(0) {|hash,pair| hash ^ pair.hash}
end