break ends the immediately enclosing loop. : break « Statement « Ruby






break ends the immediately enclosing loop.


loop do
  puts "Running..."
  print "Enter q to quit: "
  gets
  chomp
  break if $_ == "q"
end

 








Related examples in the same category

1.Break out of a block
2.Stopping an Iteration
3.Break if
4.Read till 'quit'