class Enumerator::Product

Enumerator::Product 生成任意数量的可枚举对象的笛卡尔积。迭代可枚举对象的乘积大致等同于嵌套的 each_entry 循环,其中最右侧对象的循环位于最内层。

innings = Enumerator::Product.new(1..9, ['top', 'bottom'])

innings.each do |i, h|
  p [i, h]
end
# [1, "top"]
# [1, "bottom"]
# [2, "top"]
# [2, "bottom"]
# [3, "top"]
# [3, "bottom"]
# ...
# [9, "top"]
# [9, "bottom"]

对每个可枚举对象使用的方法是 `each_entry` 而不是 `each`,这样 N 个可枚举对象的乘积在每次迭代中都会产生一个包含 N 个元素的数组。

如果没有给出枚举器,它会调用给定的块一次,生成一个空的参数列表。

这种类型的对象可以通过 Enumerator.product 创建。