The loop Method : loop « Statement « Ruby






The loop Method


# The loop method comes from Kernel. 
# It lets you run a loop continuously like running for(;;) until you or the program does something to break out of the loop.

loop do
  print "Type something: "
  line = gets
  break if line =~ /q|Q/
  puts line
end

 








Related examples in the same category