다음과 같이 튜토리얼 질문을위한 간단한 Ruby 코드를 입력했습니다. 그러나Ruby 프로그램 오류 : NoMethodError
#Grandma is deaf!
puts "Hey Sonny! It's your lovely Grandmother! How are you?"
response = gets.chomp
while response != "BYE"
if response != response.upcase
puts "Huh?! I CAN'T HEAR YOU!"
else
puts "NO! NOT SINCE " + (1930 + rand(21)).to_s + "!"
end
response = gets.chomp
end
puts "GOOD BYE, SONNY!"
, 나는이 창 표시를 실행하면 chomp
가 인식되지 않는 이유
Hey Sonny! It's your lovely Grandmother! How are you?
NoMethodError: private method ‘chomp’ called for nil:NilClass
at top level in deafGrandma.rb at line 3
이해가 안 돼요. Mac에서 textMate를 사용하고 있는데 Ruby 버전 1.8.7이 있어야합니다. 어떤 해결책?
는 너무 감사 :)
들여 쓰기/서식을 유지하려면 질문을 편집하고 코드를 4 칸 들여 쓰기해야합니다. – Adrian