Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

class · Ruby 3.4

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