walter / mwsewall.com wrote:

This will work:

irb(main):001:0> class Hash
irb(main):002:1>   def equal_content?(other)
irb(main):003:2>     {}.update(self) == {}.update(other)
irb(main):004:2>   end
irb(main):005:1> end
=> nil
irb(main):006:0> hash_a = Hash.new { |h, k| h[k] = rand }
=> {}
irb(main):007:0> hash_a[:foo] = "bar"
=> "bar"
irb(main):008:0> hash_a[:qux] = "quz"
=> "quz"
irb(main):009:0> hash_b = {:foo => "bar", :qux => "quz"}
=> {:foo=>"bar", :qux=>"quz"}
irb(main):010:0> hash_a.equal_content?(hash_b)
=> true
irb(main):011:0> {}.equal_content?(:x => 1)
=> false

Regards,
Florian Gross