From: Sandro Paganotti Date: 2008-06-13T17:07:30+09:00 Subject: Re: array to string conversion ------=_Part_10591_3863978.1213344478049 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Try this: irb(main):004:0> ex => {0=>["xls", "ini", "20080326"], 1=>["gif", "xls", "rb"]} irb(main):005:0> ex = Hash[*ex.collect{|a,b| [a,b.join(",")]}.flatten] => {0=>"xls,ini,20080326", 1=>"gif,xls,rb"} Sandro On Fri, Jun 13, 2008 at 5:53 AM, Stefano Crocco wrote: > On Friday 13 June 2008, Clement Ow wrote: > > Hi, I have 2 arrays(which is part of the hash): > > > > ex = {} > > ex[0] = ["xls", "ini", "20080326"] > > ex[1] = ["gif", "xls", "rb"] > > > > All i managed to convert is(using .to_s): > > str[0] = "xlsini20080326" > > str[1] = "gifxlsrb" > > > > but i want to convert each array into a string, something like > > str[0] = "xls,ini,20080326" > > str[1] = "gif,xls,rb" > > > > where they are seperated by a comma.. Any clean way of doin this? > > ex[0].join ',' > > Stefano > > > -- Go outside! The graphics are amazing! ------=_Part_10591_3863978.1213344478049--