Thith means war undefined method `inculde?'

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?

@coreace50300

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

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?

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 ____ = user_input.downcase!, I think you should try user_input2 = user_input.downcase!
Hope this helps!

3 Likes

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

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

1 Like

thank you for the response!

thanks again for the help!