From: 7stud -- Date: 2012-11-29T07:54:13+09:00 Subject: Re: Multidimensional Array Alan Forrester wrote in post #1086898: > On Wed, Nov 28, 2012 at 2:15 PM, John M. wrote: >> >> [['value1', value1_other1 , value1_other2], ['value2', value2_other1, >> value2_other2], ['value3', value3_other1, value3_other2]] >> >> >> Can anyone please help me in doing this > > Enumerable and array documentation are your friends: > > http://www.ruby-doc.org/core-1.9.3/Array.html > http://ruby-doc.org/core-1.9.3/Enumerable.html > > your_array = [[value1, value1_other1 ,value1_other2], [value2, > value2_other1,value2_other2], [value3, value3_other1,value3_other2]] > > new_array = your_array.collect{|y| [y[0].to_s,y[1..3]].flatten} > new_array = data.collect do |y| [ y[0].to_s, *y[1..-1] ] end -- Posted via http://www.ruby-forum.com/.