Chris Pine学习编程Ruby Ch 9:心理测试计划

age*_*fin 0 ruby methods ruby-on-rails

因此,我正在跟随Chris Pine进行心理测试[burrito,taco,wets_bed]计划...是的,我改为"Escape:The Pina Colada song"的歌词,但不然,保持不变.

然而,它仍然停留在第一个"问"上...救命?

我不想彻底改变这一点,只是想找到程序挂起的地方.

# Nice little questionnaire 

def ask question
  good_answer = false
  while (not good_answer)
    puts question
    reply = gets.chomp.downcase

    if (reply == 'yes' or reply == 'no' )
      good_answer == true
      if reply == 'yes'
        answer = true
      else
        answer = false
      end
    else 
      puts 'Please answer "yes" or "no".'
    end
  end

  answer # This is what we return (true or false)
end

puts 'Hello, and thank you for smoking.'

puts

ask 'Do you like pina-coladas?'
ask 'Do you like getting caught in the rain?'
risky_business = ask 'Do you know what your sig other likes?'
ask 'Are you into yoga?'
ask 'Do you have half a brain?'
puts 'Just a few more questions.'
ask 'Do like the feel of the ocean?'
ask 'Are you into champagne?'

puts
puts 'DEBRIEFING'
puts 'Thank\'s for all the fish'
puts
puts risky_business
Run Code Online (Sandbox Code Playgroud)

而已.我想知道这是否可能是Ruby版本问题?

谢谢!

Kev*_*imm 6

这条线路有问题吗? good_answer == true

不应该 good_answer = true