.capitalize does not capitalizes and gives no result


#1



https://www.codecademy.com/courses/ruby-beginner-en-MxXx5/0/6?curriculum_id=5059f8619189a5000201fbcb

Hello,

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.

Screenshot:

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}"


#2

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!
https://ruby-doc.org/core-2.2.0/String.html#method-i-capitalize


#3

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


#4

A value representing lack of value


#5

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