From: Love U Ruby Date: 2013-02-15T17:22:27+09:00 Subject: Re: skip iteration in each loop Saurav Chakraborty wrote in post #1097028: > I want to skip iteration for few values depending on dynamic condition. > > Say I have a persons array [1,2,3,4,5,6,7,8] and while iterating if the > one of the values equals 2, then it should skip iteration for the next > two values (in this case it is 3 and 4) > > In this case the output should be: [1,2,5,6,7,8] > > persons = [1,2,3,4,5,6,7,8] > > persons.each do |x| > if x == 2 > # the next x value should be 5 in my case > end > p x > end > > How can I do it in Ruby ? Okay! So do you want the original array intact or output to hold in a different array? clarify please? -- Posted via http://www.ruby-forum.com/.