End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
StopIteration#result
result → value
enumerator.c
View on GitHub ↗
static VALUE
stop_result(VALUE self)
{
return rb_attr_get(self, id_result);
}
Returns the return value of the iterator.
Example
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