From: Martin DeMello Date: 2003-01-23T09:02:10+09:00 Subject: Re: Definition: iterator Hal E. Fulton wrote: [I wrote] >> A method that takes in a block, and calls it on successive elements of a >> collection. > > Yes, in a sense I agree. > > I do wish we had a name for "methods that > call yield." In Ruby we've traditionally > called them "iterators" (witness the > iterator? method as David pointed out). > > That's a misleading usage, but don't blame > me for it. I didn't originate it. Hm - something involving the phrase 'coroutines', perhaps. What's the singular of coroutines? > > But on the other hand: What is a "collection"? > You say "successive" elements. Well, what > about this: > [1].each {|x| puts x} > It doesn't operate on successive elements. There > aren't any successive elements. There is only > one. Heh :) I actually expected to be called on methods like each_second, whch stretches the definition of 'successive' > And so on. If you only loop once, are you really > iterating? Or just irritating? What is the sound ROTFL!! martin