Skip to content
class · Ruby 4.0

StopIteration

< IndexError 1 instance methods

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

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

produces:

Example
Hello
Done!

Instance methods 1