From: Robert Klemme Date: 2012-12-08T19:04:44+09:00 Subject: Re: if n belongs to set a and m belongs to set b repeat some steps, How? On Sat, Dec 8, 2012 at 6:05 AM, zubair a. wrote: > We can do so in java and similar languages like: > > for (int i=0, int j=3; i<=2 && j<=5;i++,j++){ > do some repetive task until the condition becomes false... > } > > how to keep these two conditions based on two different sets(suppose two > arrays whose indexes can be used as i and j) in condition block?? > > some working code would be greatly appreciated..thanks in advance.. In this particular case it's totally useless to use two variables in the loop condition - regardless of programming language. 0.upto 2 do |i| j = i+3 ... end for i in 0..2 j = i+3 ... end Best approach depends on your actual use case. Can you give a more concrete example of what you are trying to achieve? Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/