Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions core/src/main/ruby/jruby/kernel/enumerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,14 @@ def Enumerator.product(*enums, **kwargs, &block)
class Enumerator::Product < Enumerator
def initialize(*enums, **nil)
@__enums = enums
self
end

def each(&block)
return self unless block
__execute(block, [], @__enums)
if block
__execute(block, [], @__enums)
end
self
end

def __execute(block, values, enums)
Expand Down Expand Up @@ -525,4 +528,20 @@ def rewind
end
self
end

private def initialize_copy(other)
return self if self.equal?(other)

raise TypeError if !(Product === other)

super(other)

other_enums = other.instance_variable_get(:@__enums)

raise ArgumentError.new("uninitialized product") unless other_enums

@__enums = other_enums

self
end
end
Loading