From: Austin Ziegler Date: 2006-10-21T07:20:59+09:00 Subject: Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) 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. -austin -- Austin Ziegler * halostatue@gmail.com * http://www.halostatue.ca/ * austin@halostatue.ca * http://www.halostatue.ca/feed/ * austin@zieglers.ca