So I have been reading Chris P.'s book, “Learn to Program”. I am
working through the examples and the “a Few Things to Try” sections at
the end of each chapter. I having a problem with one of them.
Here is the chapter: http://pine.fm/LearnToProgram/?Chapter=08
Basically, he wants you to write the psych question program w/o using
the variables good_answer and answer. I tried to do this in the code
below, however, when I run it in TextMate and the gets asks me for input
before puts lists the question. In other words, the first thing that
happens after I run it is the “Script is requesting input” message box.
I will note this: every now and then, the program will work properly,
but this is usually after I run the program for the first after opening
Textmate for the first time.
Thanks for your help!!
begin code here
def ask question
reply = ‘’
while (reply != ‘yes’ || reply != ‘no’)
puts question reply = gets.chomp.downcase if reply == 'yes' return true elsif reply == 'no' return false end puts 'Please answer yes or no!'
ask ‘do you like apples?’
wets_bed = ask ‘do you wet the bed?’