From: Mark Hubbart Date: 2005-10-23T09:40:49+09:00 Subject: Re: array in hash... argh!! On 10/21/05, Jamis Buck wrote: > On Oct 21, 2005, at 1:26 PM, Marco wrote: > > > hello all. > > i hope someone here can help me out. i really don't understand haw > > to do this. > > i have a hash like this: > > I'm always up for a good game of golf. :) what? did I hear "golf"? :D > > "movies"=>{ > > "title"=>["ciccio", "test", "ciccio panza"], > > "id"=>["3", "4", "1"], > > "description"=>["1", "", "hey?"], > > "insert_date"=>["2005-10-19", "2005-10-20", "2005-10-18"] > > } Not as short as some, but we gotta throw a short inject version in somewhere: h.inject([]){|a,(k,s)|i=-1;s.map{|v|a[i+=1]||={};a[i][k]=v};a} cheers, Mark