Making ruby calculator run continuously
问题 I have made a simple calculator in ruby. However after running once the program stops and has to be re-run. I tried the following but it ended in an infinite loop. How can I write this so that it will run until the users tells it to quit? puts "Please enter two digits separated by operation you would like to calculate:" input = gets.chomp.split(' ') while input != nil if input[1] == "+" puts input[0].to_i + input[2].to_i elsif input[1] == "-" puts input[0].to_i - input[2].to_i elsif input[1]