From: Robert Klemme Date: 2006-10-13T23:05:27+09:00 Subject: Re: Multiple values for the same key in a Hash On 12.10.2006 20:22, Dominic Son wrote: > Hi. There's got to be an easy way to do this. > > I simply want multiple iteams (etc, price, quantity, and name) appended > to a key.. > > There's got to be a simple way (...right?) Like this? >> 11:09:28 [~]: irbs >> require 'pp' => true >> Entry = Struct.new(:price, :quantity, :name) => Entry >> h = Hash.new {|h,k| h[k] = Entry.new} => {} >> h[:foo].price = 10 => 10 >> h[:bar].name = "bar" => "bar" >> h[:foo].name = "foo" => "foo" >> pp h {:bar=>#, :foo=>#} => nil robert