Hi --

On Fri, 20 Oct 2006, Yukihiro Matsumoto wrote:

> Hi,
>
> In message "Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8)"
>    on Fri, 20 Oct 2006 20:49:47 +0900, Jim Weirich <jim / weirichhouse.org> writes:
>
> |I don't see how an enumerator is any less a "thing" than anything else.
>
> I think he assumes a "thins" should be more array-like than an
> enumerator.  Understandable.  I have a vague plan to create something
> more array-like (but lazy like generators) and make Enumerable#map
> etc. to return "that something".  It would have (almost) all the
> methods in Array.  If String#line would give us that something, David

(Do you mean #lines?)

> would not complain, I guess.

Did you see Austin's by_* methods?

   string.lines   # an array
   string.by_lines { }   # enumeration (no intermediate array)
   string.by_lines       # enumerator (or your "something"?)

I really like that way of breaking it out.

> The points left:
>
>  * the current behavior of Enumerable methods to give enumerators if
>    they don't have blocks given.  it was introduced when enumerators
>    were made built-in.  I need to check the discussion of the time.
>
>  * the name of that something.
>
> Any opinion?

(Will come back and ponder more a little later.  How's Denver? :-)


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