> From: James Edward Gray II [mailto:james / grayproductions.net] 
> Sent: Tuesday, June 20, 2006 4:17 PM
> 
> Would someone please explain this behavior to me?
> 
>    a = [ { :foo => :bar }, { :foo => :bar } ]
> 
>    p a            #=> [{:foo=>:bar}, {:foo=>:bar}]
>    p a[0] == a[1] #=> true
>    # why does this next call do nothing?
>    p a.uniq       #=> [{:foo=>:bar}, {:foo=>:bar}]
> 
>    # inefficient work-around
>    p a.inject([]) { |cp, e| cp.include?(e) ? cp : cp << e } #=>  
> [{:foo=>:bar}]
> 
> James Edward Gray II

a = [ { :foo => :bar }, { :foo => :bar } ]

class Hash
    def hash
        self.to_a.sort.hash
    end
    
    def eql? other
        size == other.size && keys.all?{|k| self[k] == other[k]}
    end
end

p a.uniq #=> [{:foo=>:bar}]

hth

Simon