Re: Creating Hash of Arrays


#1

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. :slight_smile:

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.