From: Nikolai Weibull Date: 2006-10-20T17:51:23+09:00 Subject: Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) On 10/19/06, dblack@wobblini.net wrote: > On Thu, 19 Oct 2006, Nikolai Weibull wrote: > > Anyway, I'd love to be able to write > > > > IO.read(file).lines.each{ |line| puts line if line =~ pattern }. > 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, just that "things" sounds (to my Ruby-trained > mind :-) like a collection/array of things. But it /is/ a collection of lines. And it works just fine without an intermediate array. What I'm saying is that you may have to retrain your mind to get it to understand that a collection can be represented by other things than a plain-ol' array. I realize that you know what I'm saying above, but I figured I'd drive my point home in a concise manner as well. nikolai