From: Robert Klemme Date: 2009-12-24T21:35:06+09:00 Subject: Re: newbie: argh! array of array On 12/24/2009 12:32 AM, Alfonso Caponi wrote: > Hi forum, > > I'm fighting with a function like this! :) > > > function(["x","y","x"]) do |a,b|c| > printf("%10s %10s %10s\n",a,b,c) > end > > > It works fine, but I would like a "pseudo-code" like this :) > > > new array > > function(["x","y","z"]) do |a,b|c| > push a,b,c into array > end > > if array is not empty > printf("%10s %10s %10s\n",a,b,c) > end > > > Which is the best way to write it? I am having difficulties to figure what you want. Do you want to print arbitrary long arrays of strings with a particular formatting? If so, you can do any of these puts arr.map {|x| '%10s' % x}.join(' ') printf arr.map{'%10s'}.join(' ') << "\n", *arr Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/