On Mar 26, 2008, at 05:15 , Robert Klemme wrote:
> 2008/3/25, Ryan Davis <ryand-ruby / zenspider.com>:
>> You're not rejecting anything complicated, so it is just as easy to
>> select what you want instead of rejecting what you don't want:
>>
>> puts File.read("./src.txt").grep(/^[^#]/).join("\n")
>
> You can as well do this which is a tad shorter and probably also more
> efficient than reading into a single String:
>
> puts File.readlines("./src.txt").grep(/^[^#]/)

Only shorter because of the lack of join... which I do mostly out of  
habit but also because puts is subject to the value of $, . Granted,  
it doesn't get modified much, but I prefer to know what is going to be  
printed. Muscle memory. *shrug*

I doubt the readlines is more efficient as far as memory goes. 1  
string + 1 array + N strings vs 1 array + M strings + 1 array + N  
strings. As far as time? I dunno. I could measure but I doubt it makes  
much difference in the grand scheme of things.