From: Neil Stevens Date: 2005-12-06T00:17:34+09:00 Subject: Re: increasing counter whithin loop? Patrick Gundlach wrote: > Hi, > > a very basic question... > > I'd like to output the sequence "a b d e", by testing if the current > element is == "b" then skip the next element and continue the loop. The > obvious solution doesn't look rubyish to me, how could I use the first > or second attempt to get the desired solution? array = [1, :skip, :hidden, 2, :skip, :hidden, 3, :skip] # Zipped to ensure i is uniquely index()ed # Also makes sure use array non-destructively zip = array.zip for i in zip if i[0] == :skip zip.delete_at(zip.index(i) + 1) else puts i[0] end end Output: 1 2 3 -- Neil Stevens - neil@hakubi.us 'A republic, if you can keep it.' -- Benjamin Franklin