david,

oh, my mistake, it all ready exists! yea!

only if it would match against -1 for last index though....oh well,
can't have everything.

thanks a bunch. now i can stop making my own counters. how did i miss
that!?

~transami


On Wed, 2002-07-10 at 17:22, David Alan Black wrote:
> Hi --
> 
> On Thu, 11 Jul 2002, Tom Sawyer wrote:
> 
> > hmmm...
> >
> > don't really like the long name. alias iterate ?
> 
> I think it would be confusing not to see the familiar name.
> 
> > but then i wonder, is it possible to define iterators that recognize
> > the number of parameters and act accordingly?
> >
> > # just the object
> > arr.each  { |x|
> >   ...
> > }
> >
> > # the object with index
> > arr.each |x, i| {
> >  ...
> > }
> 
> Array#each can't really work that way -- there are too many possible
> calls that need the two arguments:
> 
>   [ [1,2], [3,4] ].each {|x,i| ... }  # etc.
> 
> but you could write an iterator that did (based on the block's arity,
> maybe).  Then again, Enumerable gives you #each_with_index for free
> :-)
> 
> 
> David
> 
> -- 
> David Alan Black
> home: dblack / candle.superlink.net
> work: blackdav / shu.edu
> Web:  http://pirate.shu.edu/~blackdav
> 
> 
-- 
~transami

"They that can give up essential liberty to obtain a little
 temporary safety deserve neither liberty nor safety."
	-- Benjamin Franklin