From: James Edward Gray II Date: 2007-04-29T04:49:46+09:00 Subject: Re: Output A File w/ Line Numbers? On Apr 28, 2007, at 12:05 PM, 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?! Right. > 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. Just be careful. In my experience the need for and index is often a hint that you haven't yet found the Ruby way to approach the problem. That's not always true, but often. > Where I had been building iterating blocks with some externally > initialized counter. See the standard generator library for doing this without a counter. James Edward Gray II