From: Bertram Scharpf Date: 2009-10-06T19:43:35+09:00 Subject: Re: new line in string Hi, Am Dienstag, 06. Okt 2009, 18:32:26 +0900 schrieb Jesús Gabriel y Galán: > 2009/10/6 Jesús Gabriel y Galán : > > On Tue, Oct 6, 2009 at 11:23 AM, Sharanya Suresh wrote: > >> How to concatenate new line character to a string? > >> > >> Eg: str = "hello"; > >>    str += '\n'; > >>    str += "world" > > BTW, if you want to concatenate to the same object, instead of > creating a new one, use this: > > str = "hello" > str << "\n" > str << "world" > #=> "hello\nworld" > > The previous idiom (+=) creates new strings. Depending on what you're doing maybe this is a good choice: %w(hello world).join $/ Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de