Ben Giddings wrote: > On Saturday, July 19, 2003, at 03:08 AM, Gavin Sinclair wrote: > > Is there a better way of doing this than > setting a counter to zero outside the loop and incrementing it inside > the loop, like this: Perhaps Array#each_with_index? array_of_stuff.each_With_index do | element, i | if element.screwy? raise "Whoa, element is screwy! #{element.inspect}, " + "look for the problem #{i} elements into the page" end result = doSomethingWithElement(element) end HTH alex __ alex fenton > counter = 1 > array_of_stuff.each { > |element| > if elementIsScrewy(element) > raise "Whoa, element is screwy! #{element.inspect}, " + > "look for the problem #{counter} elements into the page" > end > result = doSomethingWithElement(element) > ... > > counter += 1 > } > >