On Saturday, July 19, 2003, at 03:08 AM, Gavin Sinclair wrote: > Since x+=1 is rarely used in readable code, if x++ were introduced to > Ruby, it would hardly make a difference. Ok, then I have a question. Say I'm parsing a web page and have stuffed all the information into an array. I find out that somehow the data that I parsed out of the web page is screwy. The code that I previously had to deal with the information I parsed looks like: array_of_stuff.each { |element| result = doSomethingWithElement(element) ... } So I decide to take a look at each element before I do something with it: array_of_stuff.each { |element| if elementIsScrewy(element) raise "Whoa, element is screwy! #{element.inspect}" end result = doSomethingWithElement(element) ... } So now it catches that screwy element, but I want to go look at the source data to see why it's creating that screwy element, so I want to have an idea of how many elements into the page it is before there's something odd happening. Now I could change things so that I now use Array#each_index but I'm just putting in code I'll rip out once I figure out what's causing the error. 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: 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 }