# Re: Multiple values for the same key in a Hash

**URL:** <https://www.ruby-forum.com/t/re-multiple-values-for-the-same-key-in-a-hash/72613>\
**Category:** Ruby\
**Created:** [October 18, 2006, 10:39am UTC](https://www.ruby-forum.com/t/re-multiple-values-for-the-same-key-in-a-hash/72613 "2006-10-18T10:39:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 18, 2006, 10:39am UTC](https://www.ruby-forum.com/t/re-multiple-values-for-the-same-key-in-a-hash/72613/1 "2006-10-18T10:39:05Z")

</div>

> 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}
