Purpose of the answer2 = answer.capitalize line


Question... what is the purpose of the "first_name2 = first_name.capitalize" line (and same for the corresponding last_name2, city2, and state2 lines)?? I am unsure of what it is doing, if it is the first_name.capitalize! underneath it that is actually doing the capitalization.


print "What's your first name?"
first_name = gets.chomp
first_name2 = first_name.capitalize
print "What's your last name?"
last_name = gets.chomp
last_name2 = last_name.capitalize
print "Which city are you from?"
city = gets.chomp
city2 = city.capitalize
print "Which state?"
state = gets.chomp
state2 = state.upcase
puts "Your name is #{first_name} #{last_name}, and you are from #{city}, #{state}"


surNom = lastName.capitalize

This assigns the new state to the variable, without changing the actual state of lastName.


This changes the state of lastName in place.


Oooh ok, got it. Thanks for your help


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