Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class · Ruby 4.1
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!