loop() public

Repeatedly executes the block.

If no block is given, an enumerator is returned instead.

loop do
  print "Input: "
  line = gets
  break if !line or line =~ /^qQ/
  # ...

StopIteration raised in the block breaks the loop.

Show source
Register or log in to add new notes.
May 5, 2016
0 thanks

more loops

fruits = [‘apple’,‘orange”]

fruits.each do |fruit|

puts "A fruit of type: #{fruit}"