From: daniel =E5kerud [mailto:daniel.akerud / gmail.com]=20
# a =3D [Obj.new("apa", 1), Obj.new("apa", 2), Obj.new("smisk", 3)]
# =3D> [#<Obj:0x31baca8 @number=3D1, @name=3D"apa">, #<Obj:0x31bac80=20
# @number=3D2, @name=3D"apa">, #<Obj:0x31bac58 @number=3D3, =
@name=3D"smisk">]
#=20
# a.uniq
# =3D> [#<Obj:0x31baca8 @number=3D1, @name=3D"apa">, #<Obj:0x31bac80=20
# @number=3D2, @name=3D"apa">, #<Obj:0x31bac58 @number=3D3, =
@name=3D"smisk">]
#=20
# But i want only one instance of "apa", and it doesn't matter=20
# which. Is there something else I have to override?

hmm, that's a unique requirement for uniq :)
btw, there was a recent thread on removing dups, wc is similar in a way =
to uniq.

anyway, try

~> a.group_by(& :name).map{|_,v|v[0]}

=3D> [#<Obj:0xba8c90 @name=3D"smisk", @number=3D3>, #<Obj:0xba8d08 =
@name=3D"apa", @number=3D1>]

sorry, i'm in ruby1.9 box right now. but the idea is that i group the =
objects by name, and just get the first on each group.

kind regards -botp