Hi --

On Tue, 16 Dec 2008, Robert Klemme wrote:

> 2008/12/16 Vapor .. <vaqas.ashraf / gmail.com>:
>> I have a hash that contains duplicate data, for example, :username =>
>> "alex" comes many times.
>> I want to loop around and print their names just once (only unique). In
>> simple loop it would print "alex" repeatedly.
>
> irb(main):001:0> {:foo=>1,:bar=>1}.values.uniq
> => [1]
>
> You can of course have more involved solutions, e.g. (shameless self promotion):
>
> http://redhanded.hobix.com/bits/klemmeSSilentHash.html
> ;-)

hash.invert.keys   # :-)


David

-- 
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2)