On Jun 10, 8:46 pm, Robert Klemme <shortcut... / googlemail.com> wrote: > > It is usually not such a good idea to inherit base classes like Array > and Hash. Here are two more healthy approaches. > The code is meant to be getting two lists of files, one on a usb stick and one on a network share, putting them in hashes (for filename, size and md5 hash) and now i want a list of the files that are in one list but not on the other. If the hashes are the same, they won't be the same instance because they were generated seperately. Why is inheriting from Array not a healthy approach? Sorry I'm a ruby newbie. Thanks for the below info, it just seems like an overkill for what i am doing. Nicko > 1. wrap Array with a class that represents the concept (which one btw?) > your Array is used for. Then implement #- (and all the other methods). > > 2. wrap Hash with a class that represents the concept (which one btw?) > your Hash is used for. Then implement #==, #hash and #eql? accordingly. > > The basic reason why your code does not work as you would like it to > work is that Hash does not implement #eql? and #hash in a way that > considers Hash content (for the reasons please search the archives, the > topic has come up frequently). Note: > > irb(main):037:0> h={:foo=>:bar} > => {:foo=>:bar} > irb(main):038:0> h == h.dup > => true > irb(main):039:0> h.eql? h.dup > => false > irb(main):040:0> h.hash == h.dup.hash > => false > > Kind regards > > robert