From: Stefano Crocco Date: 2007-02-10T05:05:47+09:00 Subject: Re: nicer way to convert array of int to array of string Alle venerd� 9 febbraio 2007, S Kanakakorn ha scritto: > Hi, > > I'm quite new in Ruby. Here is what I wrote to convert array of > integer to array of string. I'm sure there is more compact and nicer > way to do this. Can I see the "ruby" way here ? > > def convert(intArray) > stringArray = [] > intArray.each do |i| > stringArray = stringArray + i.to_s.to_a > end > return stringArray > end > > Thanks, stringArray=intArray.map{|i| i.to_s} map passes each value of the array to the block and puts what the block returns in a array. Stefano