public Method

Kernel.loop

loop {|| block }

Repeatedly executes the block.

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

end

Source Code

/*
*  call-seq:
*     loop {|| block } 
*  
*  Repeatedly executes the block.
*     
*     loop do
*       print "Input: "
*       line = gets
*       break if !line or line =~ /^qQ/
*       # ...
*     end
*/

static VALUE
rb_f_loop()
{
   for (;;) {
       rb_yield_0(Qundef, 0, 0, 0, Qfalse);
       CHECK_INTS;
   }
   return Qnil;                /* dummy */
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.