From: Adam Bender Date: 2008-03-31T11:37:06+09:00 Subject: How does Array#- do comparisons? How does Array#- (as in, [1, 2, 3, 1, 1] - [1]) compare two objects to see if they are equal? I would think the .eql? method, but I've written a class that implements that method so that two different objects with the same values are considered equal and '-' isn't functioning as I would expect. A contrived example: irb(main):004:0> class Hash irb(main):005:1> def eql?(h) irb(main):006:2> true irb(main):007:2> end irb(main):008:1> end => nil irb(main):010:0> h1 = {'a' => 1} => {"a"=>1} irb(main):011:0> h2 = {'a' => 1} => {"a"=>1} irb(main):012:0> h1 == h2 => true irb(main):013:0> h1.eql? h2 => true irb(main):014:0> [h1] - [h2] => [{"a"=>1}] I would expect [] as a result, just like the following: irb(main):015:0> ["asdf"] - ["asdf"] => [] Thanks, Adam