On 28.04.2007 19:05, John Joyce wrote:
> So let me see if I got this close to straight:
> each_with_index is like each in that it alows you to iterate through the 
> array, but additionally hands over a counter that is also incremented?! 

Correct.

> If this is the deal, then I'm gonna have to go to rehab because of that 
> method. How useful it will be. I think for the last week I've been 
> wanting exactly that in more places than I can think of. Where I had 
> been building iterating blocks with some externally initialized counter. 
> I knew I'd missed something golden. Hadn't looked into the Enumerator 
> lib yet. Been forging through the File an IO stuff.

:-))

I suggest you take a very close look at Enumerable because that is one 
of the most often used pieces of Ruby and it's at the core of all the 
nice iterating functionality.

Then look into Enumerator which brings this functionality to all sorts 
of objects (if they provide any iterating method).

Finally, check out #inject - my personal favorite.

Kind regards

	robert