From: "Marcin Mielżyński" Date: 2008-05-12T07:55:02+09:00 Subject: Re: Array#uniq with Hash elements... can't remove duplicates andrea pisze: > Hello, > > I am having some trouble trying to remove duplicate data from an array > of hashes. I've read on the pickaxe book that Array#uniq detects > duplicates using the eql? method on the elements, but it doesn't seem to > work even if I monkeypatch the Hash class: > > class Hash > def eql? other > self == other > end > end you also need to define #hash method: class Hash def eql? other self == other end def hash h = 0 each_pair do |k, v| h ^= k.hash h *=137 h ^= v.hash end h end end lopex