In switching to Ruby 1.9 from 1.8 I notice that the behavior of the ‘$,’
output separator has changed. In Ruby 1.9 the output separator is
placed after a newline character, but this didn’t happen with Ruby 1.8.
Using the following code:
$, = ', ’
data = [[‘a’, ‘b’, ‘c’], [‘1’, ‘2’, ‘3’], [‘x’, ‘y’, ‘z’]]
file_out = File.new(“test.csv”, “w”)
data.each do |elem|
file_out.print elem[0], elem[1], elem[2], “\n”
end
file_out.close
and running with Ruby 1.8 produces a file that contains
a, b, c,
1, 2, 3,
x, y, z,
but with Ruby 1.9 the contents of the file look like
a, b, c,
, 1, 2, 3,
, x, y, z,
,
Is this an intentional change of behavior?
–Alex