From: Marnen Laibow-Koser Date: 2010-02-11T23:57:09+09:00 Subject: Re: Need help with Code (Input Functionality) Jes炭s Gabriel y Gal叩n wrote: > On Thu, Feb 11, 2010 at 7:19 AM, Raveendran .P > wrote: >> color = gets >> print "Your name is #{name.chomp}.", "You live in #{city.chomp}.", "Your >> Favorite color is #{color.chomp}." > > I think it's better to do this: > > puts 'What is your name?' > name = gets.chomp > puts 'What is your city?' > city = gets.chomp > puts 'What is your favorite color?' > color = gets.chomp > print "Your name is #{name}.", "You live in #{city}.", "Your Favorite > color is #{color}." > > Because you are probably using the variables in other places, and you > don't want to be chomping every time you use them. Or use chomp! on first call, though that's a bit less maintainable. > > Jesus. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org -- Posted via http://www.ruby-forum.com/.