user3150054
user3150054

Reputation: 909

Intro to Ruby: First Application

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

Answers (1)

Bastien Léonard
Bastien Léonard

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

Related Questions