From: Ben Lovell Date: 2009-06-26T03:24:56+09:00 Subject: Re: Ruby Output Problem --001636c9240c0b180c046d3057cf Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On Thu, Jun 25, 2009 at 7:20 PM, Mikem94590 wrote: > Hello all. > I am new to Ruby, and am created a simple program that takes a name, > and outputs "Hello " + name + ".". My problem is that this is putting > the output on multiple lines. > > e.g: Hello Mike > . > > What am I doing wrong? > > Below is the simple code I am using: > > name = gets > puts "Hello " + name + "." > sleep > > gets adds a newline so you should use chomp. Also, string interpolation is usually preferable to concatenation. This example is better: name = gets.chomp puts "hello #{name}." sleep Ben --001636c9240c0b180c046d3057cf--