On Sun, Jul 8, 2012 at 1:18 PM, Kareem Adams <lists / ruby-forum.com> wrote:
> Hi there,
>
> How do I get the below script to print the 2nd part on a single line?
>
> print 'Hello there, and what\'s your name? '
> name = gets
> puts 'Your name is ' + name + '? What a lovely name!'
>
>
> Please see below, this is how it prints:
>
> Hello there, and what's your name? Kareem
> Your name is Kareem
> ? What a lovely name!
>
> How do I get it to print like this:
>
> Hello there, and what's your name? Kareem
> Your name is Kareem? What a lovely name!'

name = gets.chomp

String#chomp removes the record separator (newline) at the end of the
string, if there is one.

http://ruby-doc.org/core-1.9.3/String.html#method-i-chomp


Kirk Haines