I've got simple statements like so:

puts "hi"
puts "there"
puts name

Wanted to adjust it to write to IO object (a string) instead of stdout.
This is the kind of construction I'd like to use:

my_out = String.new
puts my_out "hi"
puts my_out "there"
puts my_out name

But apparently that doesn't work. This seems to work

my_out << "hi" << "\n"
my_out << "there" << "\n"
my_out << name << "\n"

The lame part of that, though, is that it does not do the whole "check
if there is an end-line and add one if there isn't" magic, so I have to
manually specify the newline if I want one. I tried

my_out.puts "hi"

But evidently that does the exact opposite of want I want.
-- 
Posted via http://www.ruby-forum.com/.