On Sat, Oct 21, 2006 at 01:08:52AM +0900, dblack / wobblini.net wrote:
> What I mean is, if I've got something like:
> 
>   teacher.students
> 
> I expect/want a collection/array of students.  I'm just giving the
> simplest case, of course, but the main thing is that I'm just not sold
> on the reallocation of this method-name semantics for enumerators
> instead of arrays (or array-ish things).

Me, either, especially when we already extend the #each_ methods to
return Enumerators.

How far it will it go? Is Hash#keys going to return an Enumerator
instread of an Array? I'd rather see Hash#keys return an Array, and
Hash#each_key return an Enumerator if it wasn't passed a block, so for
pluralized method names:

   Something#XXXs = Something#each_XXX.to_a

but perhaps more efficient.

The plural returning an array is so common (Hash#keys, IO#lines, ...)
why not leave it as is, backwards compatible, especially when we can get
Enumerators from the #each_ methods when they aren't passed blocks?

Btw, I like the Foo#by_bar name idea in the sense that I think its
pretty intuitive because its what I came up with in one of my libs to
distinguish methods that iterated over a block (#each_foo) from methods
that returned an Enumerable (#by_foo). If multiple people are coming up
with the same name, it must have something obvious about it! But, since
the #each_foo methods are already there, and can do double-duty, I don't
see what the #by_ methods do that the #each_ methods don't do.

Sam