Hi --

On Thu, 19 Oct 2006, Yukihiro Matsumoto wrote:

> Hi,
>
> In message "Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8)"
>    on Thu, 19 Oct 2006 11:20:24 +0900, dblack / wobblini.net writes:
>
> |I know it's new in 1.9, and I don't like it.  I don't understand at
> |all why:
> |
> |   collection.each
> |
> |would be expected to return an Enumerator.  I find it very obscure.
>
> Perhaps we wanted to say
>
>  collection.each.with_index
>
> to utilize new-coming Enumerator class.

each still feels like an odd way to ask for an Enumerator.  I'd expect
to call a method with "enum" in the name.  The automatic Enumerator
seems to me to be a kind of "magic dot" technique -- not that there's
anything technically obscure about it (it's clear how it returns the
Enumerator), but it takes away the ability to parse the code
left-to-right based on the actual meanings and semantics of the method
names.

Even the condition "without a block" is not meaningful, in this sense.
Absence of block can be used as a flag to trigger this new behavior --
but there's nothing about the absence of a block that really *means*
that we're in an Enumerator context.


David

-- 
                   David A. Black | dblack / wobblini.net
Author of "Ruby for Rails"   [1] | Ruby/Rails training & consultancy [3]
DABlog (DAB's Weblog)        [2] | Co-director, Ruby Central, Inc.   [4]
[1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com
[2] http://dablog.rubypal.com    | [4] http://www.rubycentral.org