From: Mike Stok Date: 2013-07-10T10:38:56+09:00 Subject: Re: create variables depending on counter On 2013-07-09, at 6:03 PM, stefan heinrich wrote: > Hi marcus, > > can u say how I have to use the Hash with the headers. I have tried > everything but it doesn't work. > > Thanks > > -- > Posted via http://www.ruby-forum.com/. Hi stefan, One way you can build up an structure which mimics > Arraydog = 12, 98, 32 > Arraycar = 14, 67 might be: ratdog:~ mike$ pry [1] pry(main)> records = Hash.new { |h, k| h[k] = [] } => {} [2] pry(main)> records[:dog] << 12 => [12] [3] pry(main)> records[:dog] << 98 => [12, 98] [4] pry(main)> records[:car] << 14 => [14] [5] pry(main)> records[:car] << 67 => [14, 67] [6] pry(main)> records[:dog] << 32 => [12, 98, 32] [7] pry(main)> records => {:dog=>[12, 98, 32], :car=>[14, 67]} Hope this helps, Mike -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply.