I typed up a simple Ruby code for a tutorial question, as shown below.
#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!"
However, when I run this, the window displays:
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
I don't understand why chomp
is not recognized. I'm using textMate on a Mac I have Ruby version 1.8.7, which should be fine. Any solutions?
Thank you so much :)