From: "Jesús Gabriel y Galán" Date: 2009-10-06T18:32:26+09:00 Subject: Re: new line in string 2009/10/6 Jesús Gabriel y Galán : > On Tue, Oct 6, 2009 at 11:23 AM, Sharanya Suresh wrote: >> Hi, >> >> How to concatenate new line character to a string? >> >> Eg: str = "hello"; >>    str += '\n'; >>    str += "world" >> I must get >> hello >> world >> How it can be done? > > You nearly got it: > > str = "hello"; > str += "\n"; > str += "world" BTW, if you want to concatenate to the same object, instead of creating a new one, use this: irb(main):012:0> str = "hello" => "hello" irb(main):013:0> str << "\n" => "hello\n" irb(main):014:0> str << "world" => "hello\nworld" The previous idiom (+=) creates new strings. Jesus.