Read till 'quit' : break « Statement « Ruby






Read till 'quit'


while(line = gets.chop)     
  break if line == "quit"   
  puts eval(line)
end
puts "Good bye"             

 








Related examples in the same category

1.break ends the immediately enclosing loop.
2.Break out of a block
3.Stopping an Iteration
4.Break if