Looping Through Multiple Iterables in Parallel : SyncEnumerator « Development « Ruby






Looping Through Multiple Iterables in Parallel


require 'generator'

enumerator = SyncEnumerator.new(%w{Four seven}, %w{score years},
                                %w{and ago})
enumerator.each do |row|
  row.each { |word| puts word }
  puts '---'
end

enumerator = SyncEnumerator.new(%w{Four and}, %w{score seven years ago})
enumerator.each do |row|
  row.each { |word| puts word }
  puts '---'
end

 








Related examples in the same category