Hi Rodrigo,

Check out Enumerable#find.
http://ruby-doc.org/core-2.0/Enumerable.html#method-i-find

With a hash it'll look something like this:
hsh.find { |key, value| value[:yourkey] == yourvalue }

That should get you on the right track.

Cheers,
Jason



On Fri, Jun 28, 2013 at 1:21 PM, Rodrigo Lueneberg <lists / ruby-forum.com>wrote:

> array = {:id=>1, :price =>0.25} # index[0]
>   {:id=>2, :price =>0.35} # index[1]
>   {:id=>3, :price =>0.25} # index[2]
>
> I am beginning to adventure in Ruby and I need to find in this array of
> hashes the id with the value of 3 and get its price. What would be the
> easiest way to do it?
>
> Thanks
>
> --
> Posted via http://www.ruby-forum.com/.
>
>