-1
下面是一些代碼:未定義的方法`include?'對於零:NilClass紅寶石初學者
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
它工作得很好。任何想法爲什麼這是?
感謝您的澄清。 –