In programming class, we are creating a program to translate a sentence to Pig Latin. We are specifically told to use methods, and one of the given ones for all assignments is that we could re-run it as many times as we want to. The normal code for the latter works in the sense that if we type "no", it exits. However, if we put it in a method and call it at the end of the while loop, it acts as if we typed "yes", with no regard to what we actually typed.
def ask_again()
puts "Go again? "
again = gets.chomp
until again.downcase == "yes" || again.downcase == "no"
puts "Please answer with \"Yes\" or \"No\""
again = gets.chomp
end
if again == "yes"
continue = true
else
continue = false
end
end
#Main Program
while continue
get_input()
tokenize($input).to_s + "\n" #Ignore these three methods
scramble_sentence($input)
ask_again() #This is the method I am referring to.
end