这是一些代码:
print "What is your name?"
userinput = gets.chomp.downcase!
if userinput.include? "s"
print "I found it"
else
print "found nothing"
end
它给出了错误:未定义的方法“包括?” 对于零:NilClass
但是当我将其更改为:
print "What is your name?"
userinput = gets.chomp
userinput.downcase!
if userinput.include? "s"
print "I found it"
else
print "found nothing"
end
它工作得很好。知道这是为什么吗?