From: "Jan E." Date: 2012-12-08T16:17:24+09:00 Subject: Re: if n belongs to set a and m belongs to set b repeat some steps, How? Hi, so you want to iterate parallely over two arrays? There are many ways to do that in Ruby. The most comfortable solution is probably using Array#zip: as, bs = [2, 4, 6], [10, 20, 30, 40] as.zip bs do |a, b| puts "a: #{a}, b: #{b}" end You can also use Enumerators: each_a, each_b = as.each, bs.each loop do a, b = each_a.next, each_b.next puts "a: #{a}, b: #{b}" end And a low level Java-like solution would be 0.upto [as.length, bs.length].min - 1 do |i| puts "a: #{as[i]}, b: #{bs[i]}" end -- Posted via http://www.ruby-forum.com/.