Project

General

Profile

This project is closed and read-only.

Bug #852 ยป generator.rb.diff

knu (Akinori MUSHA), 12/11/2008 02:07 PM

View differences:

lib/generator.rb (working copy)
# In the latter, the given block is called with the generator
# itself, and expected to call the +yield+ method for each element.
def initialize(enum = nil, &block)
if enum
if @enum = enum
@block = proc { |g|
enum.each { |x| g.yield x }
}
......
# Rewinds the generator.
def rewind()
if @enum && @enum.respond_to?(:rewind)
@enum.rewind
end
initialize(nil, &@block) if @index.nonzero?
self
    (1-1/1)