Is my code redundant?


Here is a link to the lesson I just finished.

I am not getting any error messages, but I feel like my code is redundant. These two statements seem to do the same thing. Is one just shorthand?

first_name = first_name.capitalize

print "What is your first name?"
first_name = gets.chomp
first_name = first_name.capitalize
print "What is your last name?"
last_name = gets.chomp
last_name = last_name.capitalize
print "What city are you from?"
city = gets.chomp
city = city.capitalize
print "What state are you from?"
state = gets.chomp
state = state.upcase
puts "Is this correct? #{first_name} #{last_name}, #{city}, #{state}"


I believe you have to do the first of the two because you are overwriting your variable. It would work if you did the second one but not overwrite it. I don't believe that you need to do both though...


last_name = last_name.capitalize

nickgrimes50 is correct, these do the same thing.
but the one you should use is the second line, not the first (it is more efficient, and is what they are asking us to do).
The ! after a method overwrites the variable with the new value, so it is the same as the "last_name =" part.