Thith means war undefined method `inculde?'


#1

I keep getting the

undefined method `inculde?' for nil:NilClass

no matter how many changes I make.

print "type something"
user_input=gets.chomp
user_input = user_input.downcase!
if user_input.include? "s"
print "hi"
end

Can someone tell me what I am doing wrong or why I keep getting this error?


#2

@coreace50300

Hi, there isn't really much wrong with your coding, you just spelt 'include' wrongly,
try using 'include?' instead!
Hope this helps!


#3

Hi,

Thanks for you reply but that was just a typo when writing my question.

print "type something"
user_input=gets.chomp
user_input = user_input.downcase!
if user_input.include? "s"
print "blah blah"
end

And I still get the error. Anyone know what's up?


#4

Hi,

Oh, I see. Just saw your coding again, maybe you should write on line 3 of your code:
user_input.downcase! instead of,
user_input = user_input.downcase! as this causes user_input(which is already a variable that you declared) to be declared once again.
If you do one to write ___ = userinput.downcase!, I think you should try user_input2 = user_input.downcase!
Hope this helps!


#5

I just started learning, but i think this validation has some kind of glitch. I had the same code, and i've used .chomp before on my gets and it always has worked, but when you remove the .chomp, and just have the method .downcase! it works, and allows you to continue.

Maybe someone with greater Ruby knowledge can confirm if this is an actual glitch?

Thanks


#6

This was super helpful. I tried putting the .downcase command on a different line and got the code to work. Thanks!


#7

thank you for the response!


#8

thanks again for the help!