On 12/2/06, jansenh <henning.jansen / gmail.com> wrote:
> what is the ruby-way of comma separating the output from array.to_s?

A quick way to generate CSV file from an array of arrays is to take
advantage of the fact that Ruby array constant looks a lot like a CSV
record:

-------------
irb(main):001:0> a = [1,'two',"III",4]
=> [1, "two", "III", 4]
irb(main):002:0> a.inspect
=> "[1, \"two\", \"III\", 4]"
irb(main):003:0> puts a.inspect
[1, "two", "III", 4]
=> nil
irb(main):004:0> puts a.inspect[1...-1]
1, "two", "III", 4
=> nil
-------------

I learned this trick reading Hal Fulton's excellent "Ruby Way (2nd ed)".

Cheers,

Luciano