.capitalize does not capitalizes and gives no result




I have noticed that if I enter already capitalized answer to the question, puts .capitalized function does not give any answer - it's just an empty space. But if I enter a lowercase answer inside the question, it gives capitalized answer.


Why is it so?

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

print "What's your last name?"
last_name = gets.chomp.capitalize!
puts "Your last name #{last_name}"

print "What city are you from?"
city = gets.chomp.capitalize!
puts "You're from #{city}"

print "What state are you from?"
state = gets.chomp.upcase!
puts "State: #{state}"


Read up on anything that you don't already know how it behaves before using it

Look up capitalize and capitalize! .. and also upcase and upcase!


Ok, i get it now and what's that NIL


A value representing lack of value


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