From: dblack@... Date: 2006-10-19T06:08:15+09:00 Subject: Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) Hi -- On Thu, 19 Oct 2006, Nikolai Weibull wrote: > On 10/18/06, Mauricio Fernandez wrote: >> On Thu, Oct 19, 2006 at 04:24:24AM +0900, Nikolai Weibull wrote: >> > On 10/18/06, mathew wrote: >> > >On 10/18/06, Nikolai Weibull wrote: >> > >> On 10/18/06, Eric Hodel wrote: >> > >> > Creating a new Array for enumerating the lines of a 50M String is >> not >> > >> > going to be fun (or fast). >> > >> >> > >> When would you actually do that? >> > > >> > >If you mean "When would you enumerate the lines of a 50M String?", one >> > >answer is when doing molecular biology. Lots of biotech companies use >> > >Perl to analyze DNA sequences, which are enormous Strings. The human >> > >genome is about 650MB. >> > >> > That's not what I meant. Substitute "such a thing as creating a new >> > Array for enumerating the lines of a 50M String" for "that". >> >> e.g. >> >> largestring.lines.min >> >> if String#lines returned an array instead of an enumerator, making it >> equivalent to >> >> largestring.lines.to_a.min > > I'm missing something vital here. Why would #lines return an array? > Are we talking about David Black's "#lines sounds like it should > already be an array" comment here, or what? I think so, but I think also my comment was misunderstood as "no method, of any name, should ever return an enumerator." :-) The part I'm not comfortable with is, indeed, the method names. each_* not taking a block strikes me as odd; I'm not convinced the "each" naming would ever have been used in the language if not for blocks, and I don't think it retrofits very well. lines sounds like a collection. 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