On Fri, 25 Apr 2003 15:55:06 +0900
Dave Thomas <dave / pragprog.com> wrote:

<snip> 
> Or, have each class that wants to support this protocol define a method 
> 'each_foo'. Then have enumerable implement 'each_with_foo' as
> 
>    module Enumerable
>      def each_with_foo
>        each_foo {|foo| yield self[foo], foo}
>      end
>    end

This is perhaps an OK default, but it would be nice to see a O(1)
iterator for Hash eventually. ;)

<snip> 
> However, how often to you want to do an each_with_index polymorphically?

This is the point of the addition---I want to access every Enumerable
from Enumerable, to be able to replace and restore references to
Marshalled objects (so other objects stored with an OID don't get
cloned by the store/load).  It's better to do this once in Enumerable
than for every class individually.

There are, I'm sure, a myriad of uses for e[k] == i, though.  Not having
to look up the method for every class ought to be one. ;)

-- 
Ryan Pavlik <rpav / users.sf.net>

"These monkeys of which you speak... are they mentally
 deficient by human or monkey standards?" - 8BT