Tuesday 27 August 2013

gets.chomp method excercise in learn to program book

gets.chomp method excercise in learn to program book

I'm new to programming/Ruby. I am doing excercise 5.6 out of "Learn to
Program" for a class. I have the following:
puts 'What\'s your first name?'
first = gets.chomp
puts 'What\'s your middle name?'
middle = gets.chomp
puts 'What\'s your last name?'
last = gets.chomp
puts 'Hello, Nice to meet you first middle last'
And I have tried the following:
puts 'What is your first name?'
first = gets.chomp
puts 'What is your middle name?'
middle = gets.chomp
puts 'What is your last name?'
last = gets.chomp
puts 'Hello, Nice to meet you #{first} #{middle} #{last}'
When I get the last "puts" it won't get the first, middle and last name
that I wrote in. It says, "Hello, nice to meet you first, middle,
last....Instead of Joe John Smith for example. What am I doing wrong?
Thank you so much for your help! I really appreciate it!

No comments:

Post a Comment