In Files

    • enumerator.c

    Parent

    Methods

    Class/Module Index [+]

    Quicksearch
    No matching classes.

    StopIteration

    Raised to stop the iteration, in particular by . It is rescued by .

    loop do
     puts "Hello"
     raise StopIteration
     puts "World"
    end
    puts "Done!"
    

    produces:

    Hello
    Done!
    

    Public Instance Methods

    result → value click to toggle source

    Returns the return value of the iterator.

    o = Object.new
    def o.each
     yield 1
     yield 2
     yield 3
     100
    end
    e = o.to_enum
    puts e.next #=> 1
    puts e.next #=> 2
    puts e.next #=> 3
    begin
     e.next
    rescue StopIteration => ex
     puts ex.result #=> 100
    end
    
     static VALUE
    stop_result(VALUE self)
    {
     return rb_attr_get(self, id_result);
    }
     

    This page was generated for Ruby

    is a service of and , purveyors of fine dance noise.

    Generated with Ruby-doc Rdoc Generator 0.44.0.