From: dblack@... Date: 2006-10-19T20:36:28+09:00 Subject: Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) 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. Otherwise -- if lines is an enumerator, rather than some lines -- it feels to me like Ruby is taking over too much. It's as if I'm being allowed to say "I want lines from this string", but Ruby knows better: I don't *really* want lines, even if I think I do. That kind of steering away from the semantics of the method names makes me uncomfortable. If I need an enumerator, I want the language to give me a way to ask for one clearly; and if I ask for "things", I want the things. 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