Reputation: 909
Anyone know why even though I enter in "Raphael" I still get the you are not the owner output?
print "Who are you:"
name = gets().capitalize
if (name != "Raphael") then
print "You are not the owner of Genesis"
else
puts ("Oh, hello #{name}...")
end
Upvotes: 0
Views: 49
Reputation: 61833
gets()
includes the newline character you entered when pressing Enter.
Try using gets.capitalize.chomp
.
If you want to know more about chomp()
: http://ruby-doc.org/core-2.2.0/String.html#method-i-chomp
Upvotes: 3