On 6/20/06, Matthew Smillie <M.B.Smillie / sms.ed.ac.uk> wrote:
> On Jun 20, 2006, at 15:17, James Edward Gray II wrote:
>
> >   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}]
>
> Seems to compare on object id, rather than with ==.  I couldn't
> speculate on any more significant answer to 'why?'
>
> a[0].id == a[1].id
> => true
>
> b = [a[0], a[0]]
> b.uniq
> => [{:foo=>:bar}]
>

Not comparing on id:

irb(main):006:0> [['a'],['a']].each{|ar| puts ar.id}
99017932
99017908
=> [["a"], ["a"]]
irb(main):007:0> [['a'],['a']].uniq
=> [["a"]]
irb(main):008:0>