Skip to content
instance method

StopIteration#result

() -> untyped
result → value

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
also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0