Hi Ryan,
I didn't modify a core class. EnumerableArgs is a complete rewrite of
Enumerable and stands on it own.
Sorry I was ambiguous. In the ObjectSpace example you modify a core class:
class << ObjectSpace
include EnumerableArgs
alias :each, :each_object
end
ObjectSpace.select(Class) { |c| c.name =~ /^S/ }
Though this modification is less troublesome than other kinds of changes.
The Enumerator approach lacks for a few reasons.
1. Its' longer and less readable.
Here is the code from Pit:
require "enumerator"
ObjectSpace.enum_for(:each_object, Class).select { |c| c.name =~ /^S/ }
How is that longer than your example above? If the unneeded whitespace
is removed from both, your example is about 50 characters longer (this
is ignoring the needed "require" line, since your example lacks it.)
And maybe I'm "in too deep" in understanding Ruby, but I find the
above very readable (but I also find inject easy to understand now
too, so...)
And while your example is also pretty easy to read, it requires some
knowledge as to what EnumerableArgs is, since the name isn't totally
obvious.
2. It's creates an intermedeary object.
Fair enough.
4. It means Enumerable remains less useful.
What happened to number 3? 
I'm not arguing that the code you made doesn't have some merit, I just
don't agree that it is any better than the enumerator example.
While Enumerator may have it's uses, I do not find it's use here
"Ruby-esque", for much the same reason David disliked #every --I have
to agree.
Well it seems the perspective of something being "Ruby-esque" is quite
subjective, since I find the enumerator example quite "Ruby-esque."
Regards,
Ryan
···
On 10/30/05, Trans <transfire@gmail.com> wrote: