On 6/28/2013 5:58 PM, Rodrigo Lueneberg wrote:
> I am sorry, I did not understand what you tried to convey. To me it is
> clear that is an array of hashes. I just don't get your example..
>
He means your example code did not produce and array.  Consider the 
following irb session:

irb(main):003:0> array = {:id => 1, :price => 0.25}
=> {:id=>1, :price=>0.25}
irb(main):005:0> {:id => 2, :price => 0.35}
=> {:id=>2, :price=>0.35}
irb(main):006:0> {:id => 3, :price => 0.25}
=> {:id=>3, :price=>0.25}
irb(main):007:0> array
=> {:id=>1, :price=>0.25}
irb(main):008:0> array.class
=> Hash

That's because you need to put your array in a comma separated list of 
values inside []:
irb(main):026:0> array = [{ :id => 1, :price => 0.25 },
irb(main):027:1* { :id => 2, :price => 0.35 },
irb(main):028:1* { :id => 3, :price => 0.25 }]
=> [{:id=>1, :price=>0.25}, {:id=>2, :price=>0.35}, {:id=>3, :price=>0.25}]

Now that we have an array, we can find the element with the id of 3 like so:
irb(main):029:0> item = array.find {|hash| hash[:id] == 3 }
=> {:id=>3, :price=>0.25}

and get it's price:
irb(main):030:0> item[:price]
=> 0.25

Hopefully that helps.

Walton