A
Alan Munn
Hi, I'm new to ruby, and am having trouble with the following (\n is
newline on a Mac).
e.g.
line = "foo bar"
line = line.sub(/ /, '\n')
puts line
This produces:
foo\nbar
when what I want (and expected) was:
foo
bar
(This is just a toy example; I don't actually want to split lines on
spaces.) What I don't understand is how to insert a true newline into a
string so that it outputs as such.
Thanks
Alan
newline on a Mac).
e.g.
line = "foo bar"
line = line.sub(/ /, '\n')
puts line
This produces:
foo\nbar
when what I want (and expected) was:
foo
bar
(This is just a toy example; I don't actually want to split lines on
spaces.) What I don't understand is how to insert a true newline into a
string so that it outputs as such.
Thanks
Alan