Re: Multiple values for the same key in a Hash

From: Dominic S.
Yes, i was thinking your later suggestion, but how do i
iterate through
them…

the price, and quanity come back too containated (ie : 1.995
) do i have
to mess with a .split and reg exp at this point? please say
it isn’t so!

It isn’t so.

irb(main):001:0> my_hash = {}
=> {}
irb(main):002:0> my_hash[ :key ] = { :price => 1.99, :quantity => 5 }
=> {:price=>1.99, :quantity=>5}
irb(main):003:0> puts my_hash[ :key ][ :price ]
1.99
=> nil
irb(main):004:0> my_hash[ :key ].each{ |key,value| puts “The #{key} is
#{value}” }
The price is 1.99
The quantity is 5
=> {:price=>1.99, :quantity=>5}