From: "Berger, Daniel" Date: 2006-05-23T05:38:06+09:00 Subject: Re: Creating Hash of Arrays > -----Original Message----- > From: Paul D. Kraus [mailto:paul.kraus@gmail.com] > Sent: Monday, May 22, 2006 2:28 PM > To: ruby-talk ML > Subject: Creating Hash of Arrays > > > How can I create a hash that contains an array for its value? > How can I then loop through the hash keys and intern the > contained arrays. > > Pseudo Code > ------------------ > myhash['customercode'][0]=Firstname > myhash['customercode'][1]=M.I myhash['customercode'][2]=Lastname > > myhash.each do |k,v| > myhash['k'].each do |elm| > puts "#{k} -> elm" > end > end Except for a line break or semicolon between the 2nd and 3rd assignment, I think your pseudo code will work. Did you try it? irb is your friend, btw. :) However, this is Ruby not Perl. There's no need to use deeply nested hash structures when you want an object in Ruby. class CustomerCode attr_accessor :first_name, :mi, :lastname end array_of_customers.each do |cust| cust.first_name = some_first_name cust.mi = some_mi cust.last_name = some_last_name p cust end Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.