-----Original Message-----
> From: dblack / rubypal.com [mailto:dblack / rubypal.com] On 
> Behalf Of dblack / wobblini.net
> Sent: Thursday, October 19, 2006 10:06 AM
> To: ruby-core / ruby-lang.org
> Subject: Re: String not enumerable, what about IO? (was Re: 
> Symbol < Stringin Ruby > 1.8)
> 
> 
> Hi --
> 
> On Thu, 19 Oct 2006, Nikolai Weibull wrote:
> 
> > On 10/19/06, dblack / wobblini.net <dblack / wobblini.net> wrote:
> >> 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 20:16:54 +0900, 
> dblack / wobblini.net writes:
> >> >
> >> > |There are two separate questions involved, though:
> >> > |
> >> > |   1. Should there be a method to enumerate over the 
> lines without
> >> > |      creating an intermediate array?
> >> > |   2. Should that method be called "lines"?
> >> > |
> >> > |I would say yes to #1, and no to #2.
> >> >
> >> > The reason behind no to #2 is that readlines returns an array, 
> >> > right? Then, what if I change readlines to return Enumerator?
> >> 
> >> I still think the naming is very unexpected.  I know it's 
> >> old-fashioned and naive to expect "things" to be a collection of 
> >> things :-)  But I really do have that expectation.
> >
> > I think it's rather nice, and it actually /is/ a collection of 
> > "things", although more of what may be thought of as a lazy 
> list that 
> > will give you another one of the "things" each time you 
> need it, not 
> > all at once in an array.  One really has to get away from 
> treating all 
> > collections as if they're always going to be arrays of "things". 
> > Sadly, it's the C in us that makes us think/read/talk in 
> that manner 
> > [1].
> 
> Actually in my case it's the Ruby in me :-)
> 
> > Anyway, I'd love to be able to write
> >
> > IO.read(file).lines.each{ |line| puts line if line =~ pattern }.

Why do we need this when we already have IO.foreach?
 
> If lines were a collection of lines, you could do exactly 
> that.  And, just to say it again, I'm not saying that there 
> should be no methods that return Enumerators...

<snip>

But I am.  This is a bad case of overengineering IMHO.

Regards,

Dan


This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly 
prohibited and may be unlawful.  If you have received this communication 
in error, please immediately notify the sender by reply e-mail and destroy 
all copies of the communication and any attachments.