A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.ruby-lang.org/en/master/StopIteration.html below:

class StopIteration - Documentation for Ruby 3.5

class StopIteration

Raised to stop the iteration, in particular by Enumerator#next. It is rescued by Kernel#loop.

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

produces:

Hello
Done!
Public Instance Methods

Source

static VALUE
stop_result(VALUE self)
{
    return rb_attr_get(self, id_result);
}

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                   
puts e.next                   
puts e.next                   

begin
  e.next
rescue StopIteration => ex
  puts ex.result              
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4