Forum: Ruby Dead Grandma (3 byes) -- Chris Pine Rube site

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
2b92e305d59abf088d0a78b841687b9b?d=identicon&s=25 Mike W. (mikewayne)
on 2016-12-29 09:49
I get the "right" outputs and the program exits when it's supposed to,
but just having trouble with having to start the counter of "bye" at 1.
Help on a bit of refactoring please -- or even a much-improved way to
get there?  Thank you.

bye = 1

while true
  puts "Hey Sonny! It's your lovely grandma! How are you?"
  response = gets.chomp

  if bye == 3
    puts "BYE!"
    exit 100
  elsif (response.upcase == "BYE")
    puts "Huh?! I can't hear you!"
    bye = bye + 1
    puts "bye = " + bye.to_s
  elsif response != response.upcase
      puts "No! Not since 19" + rand(30..51).to_s + "!"
This topic is locked and can not be replied to.