Why wont the computer print out my answers


#1

is there something wrong with my code??


#2

Hi you fogot to put puts your code should be like that

print "What's your first name?"
first_name = gets.chomp
puts "Your name is #{first_name}"

inside the puts you should put the variable first_name inside #{ }


#3

got it!
thanx for the help


#4

another question.
what does the gets.chomp do?


#5

It gets input from the user and chomps off the trailing line break that comes with.


#6

i didnt really understand


#7

That's okay, but it will be easier to answer you if I know what part you don't understand.

You are writing a computer program.
You want to get some in information for your user.
Maybe you want to get their first name and store it in a variable called first_name so you can use it later.
So you write a line of code that gets this data for you, like this:

first_name = gets

You probably noticed, when you ran your program, that you typed your first name then pressed enter/return?
You don't want that enter/return to be part of the data stored in the first_name variable so you chomp it off.

first_name = gets.chomp