Laksakan Laksakan - 5 months ago 9
Ruby Question

Spacing issue in Ruby

I have the following code:

puts 'Hello, what\'s your first name?'
firstName = gets.chomp
puts 'What is your middle name?'
middleName = gets.chomp
puts 'Finally, what is your last name?'
lastName = gets.chomp
puts 'Nice to meet you ' + firstName + middleName + lastName + '. :)'


The last part does not space out. Please help.

Answer

Try this:

puts 'Nice to meet you ' + firstName + ' ' + middleName + ' ' + lastName + '. :)'