class Enumerator::Product

def __execute(block, values, enums)

def __execute(block, values, enums)
  if enums.empty?
    block.yield values
  else
    enum, *enums = enums
    enum.each do |val|
      __execute(block, [*values, val], enums)
    end
  end
  nil
end

def each(&block)

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

def initialize(*enums)

rubocop:disable Lint/MissingSuper
def initialize(*enums)
  @__enums = enums
end

def initialize_copy(other)

def initialize_copy(other)
 self if equal?(other)
TypeError unless Product === other
other)
enums = other.instance_variable_get(:@__enums)
ArgumentError, "uninitialized product" unless other_enums
ms = other_enums

def rewind

def rewind
  @__enums.each do |enum|
    enum.rewind if enum.respond_to?(:rewind)
  end
  self
end

def size

def size
  total_size = 1
  @__enums.each do |enum|
    return nil unless enum.respond_to?(:size)
    size = enum.size
    return size if size == 0 || size == nil || size == Float::INFINITY || size == -Float::INFINITY
    return nil unless size.is_a?(Integer)
    total_size *= size
  end
  total_size
end