File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -141,10 +141,10 @@ def flat_map(&block)
141141 #
142142 # @return [Promise]
143143 def zip ( *others )
144- others . reduce ( self ) do |p1 , p2 |
145- p1 . flat_map do |result1 |
146- p2 . then do |result2 |
147- [ result1 , result2 ] . flatten
144+ others . reduce ( self . then { | x | [ x ] } ) do |p1 , p2 |
145+ p1 . flat_map do |results |
146+ p2 . then do |next_result |
147+ results << next_result
148148 end
149149 end
150150 end
Original file line number Diff line number Diff line change @@ -294,12 +294,12 @@ module Concurrent
294294 describe '#zip' do
295295 let ( :promise1 ) { Promise . new ( executor : executor ) { 1 } }
296296 let ( :promise2 ) { Promise . new ( executor : executor ) { 2 } }
297- let ( :promise3 ) { Promise . new ( executor : executor ) { 3 } }
297+ let ( :promise3 ) { Promise . new ( executor : executor ) { [ 3 ] } }
298298
299299 it 'yields the results as an array' do
300300 composite = promise1 . zip ( promise2 , promise3 ) . execute
301301 sleep 0.1
302- expect ( composite . value ) . to eq ( [ 1 , 2 , 3 ] )
302+ expect ( composite . value ) . to eq ( [ 1 , 2 , [ 3 ] ] )
303303 end
304304
305305 it 'fails if one component fails' do
You can’t perform that action at this time.
0 commit comments