how can I break out of the loop by user input example input other than yes will just break me out of the loop enter image description here
CodePudding user response:
def main
loop do
# ...
puts "Repeat for another input?"
ans = gets.chomp
if ans != "yes"
break # will break the loop
end
end
end
main