On Fri, Jun 28, 2013 at 7: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?
>

There is no Array:

ruby <<XXXX
array = {:id=>1, :price =>0.25} # index[0]
  {:id=>2, :price =>0.35} # index[1]
  {:id=>3, :price =>0.25} # index[2]

p array
XXXX
{:id=>1, :price=>0.25}

Cheers

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/