Don't know where is the problem


Hi guys,
I don't know where is the problem. Can you help?

print "whats your name?"
user_imput = gets.chomp

user_imput.include? ( "s" || "S" )
print "ok"

It seems like I "forget to call .include? on user_input."
how to correct it?

Daffy Duck, .include? not recognized?

Compare the spelling to your code.


user_input or user_imput doesn't matter because is a variable

Also I'm stuck in here, it says that i forgot to call .include?

print "hi"
user_input = gets.chomp
if user_input.include? "S"
print user_input
else print "HAS NO S"


User input cannot be an empty string, .downcase! and .upcase! methods return nil if no changes are made. This will raise the undefined method error.

The exercise uses .downcase! so the input must contain at least one capital letter. The work around is to write the modifier as an assignment, rather than in place.

user_input = gets.chomp.downcase


user_input = gets.chomp
user_input = user_input.downcase

This way it doesn't matter what the user inputs. Both of the above will work and pass.


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