I'm confused



IER, expecting $end
first_name = "Gabe"answer.capitalize

print "What's your first name?"
var = first_name
first_name = gets.chomp
print "What's your last name?"
var = last_name
last_name = gets.chomp
print "What city are you from?"
var = city
city = gets.chomp
print "What state are you from?"
var = state
state = gets.chomp
first_name = "Gabe"answer.capitalize


You should either use capitalize method on variable "answer" or "Gabe" string.


I know that, but I don't know what it means by the answer string and I don't know where to put it.


This part of your code seems wrong.
Either try: "Gabe".capitalize
or: answer.capitalize

You should also skip parts where i guess you try to define a variable this way: var = ...
You don't need that and i guess it also could give errors.
For example first_name = gets.chomp already declares variable first_name. This line both declares and assignes value, which in this case is user's input.

Also if the last line of your code is supposed to puts user's first name capitalized, you could just type: puts first_name.capitalize


Are you coming to Ruby from Javascript perhaps? The 'var' keyword is unnecessary in Ruby, get rid of all those lines and you'll be fine :slight_smile:

In short:

Variable in Ruby, at their simplest, can be defined without stating they are variables.

first_name = "geno922" --- This is perfectly fine and all that's needed.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.