From: dblack@... Date: 2006-10-21T11:32:45+09:00 Subject: Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) Hi -- On Sat, 21 Oct 2006, Austin Ziegler wrote: > On 10/20/06, Sam Roberts wrote: >> On Sat, Oct 21, 2006 at 01:11:36AM +0900, dblack@wobblini.net wrote: >> > Did you see Austin's by_* methods? >> > string.lines # an array >> > string.by_lines { } # enumeration (no intermediate array) >> This is identical to ruby1.8's string.each_line {} >> >> > string.by_lines # enumerator (or your "something"?) >> >> This is identical to ruby1.9's string.each_line. >> >> > I really like that way of breaking it out. >> >> I like the functionality, and #lines, but why not keep using "each_" >> instead of "by_"? > > Because the problem is #lines, not #each_line. My understanding is > that ultimately Ruby 1.9 wont have String#each_line at all, and you'll > instead have to do String#lines#each to get this. More, String#lines > without #each returns an enumerator. So, instead of String#lines, use > String#by_lines. Where I personally disagree with David is that we > shouldn't have String#lines at all. I'd rather have > String#by_lines#to_a. I would certainly rather have no #lines than have it return an Enumerator. 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