backports 1.6.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/backports/array.rb +5 -6
- metadata +1 -1
data/VERSION.yml
CHANGED
data/lib/backports/array.rb
CHANGED
@@ -105,13 +105,12 @@ class Array
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def product(*arg)
|
108
|
-
|
109
|
-
|
110
|
-
arrays.inject(first_enum) do |enum, array|
|
108
|
+
trivial_enum = Enumerator.new{|yielder| yielder.yield [] }
|
109
|
+
[self, *arg].inject(trivial_enum) do |enum, array|
|
111
110
|
Enumerator.new do |yielder|
|
112
|
-
|
113
|
-
|
114
|
-
yielder.yield [obj]
|
111
|
+
enum.each do |partial_product|
|
112
|
+
array.each do |obj|
|
113
|
+
yielder.yield partial_product + [obj]
|
115
114
|
end
|
116
115
|
end
|
117
116
|
end
|