From: "Simon Kröger" Date: 2006-05-23T05:35:53+09:00 Subject: Re: Creating Hash of Arrays Paul D. Kraus schrieb: > 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 ruby code: ------------------ myhash = Hash.new{|h, k| h[k] = [nil] * 3} 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 output: ------------------- customercode -> Firstname customercode -> M.I customercode -> Lastname does that help? Simon