I am fairly new to ruby, and I have just started listening to this mailing
list, so please don't flame me too much if I get things wrong!

----- Original Message -----
From: "Mauricio Fernandez" <mfp / acm.org>
>
> What about:
> * defining String#to_enum, which would accept an argument (:lines, :chars
or
>   :bytes) defaulting to :lines. Note that right now (in HEAD)
"foo".to_enum
>   ends up using Kernel#to_enum, raising a NameError (undefined #each for
class
>   String).
> * making  str.lines (chars, bytes) equivalent to
>   str.to_enum(:lines).to_a  (respectively :chars, :bytes)

Though I have never used it, doesn't Ruby already have something (admitedly
rather long-winded) to do this called Enumerable::Enumerator?

I would also like to add my 2 cents worth to this discussion.

I have found Enumerables rather confusing, as there are many variants of
"each" in a number of different classes.

What I would prefer (and this would probably be a major change to the
implementation) is to be able to treat ALL enumerable classes as Arrays. In
other words, I'd like to suggest that Array and Enumerable effectively be
the same thing, and that "Array" would be the superclass instead of
"Enumerable".

Of course this would only be on the surface - underneath the implementation
of each would probably have to be different for efficiency.

Thius would add possibly useless methods like Range#[], but why not?

Most enumerable classes are ordered, so the Array#[] method would work fine.
Hashes are an exception, and obviously Hash#[] would be different.

Then perhaps either the "to_a" or "split" methods could be used to convert
Strings and IOs to Arrays?

Regards,
Mike