Hi --

On Wed, 18 Oct 2006, Nobuyoshi Nakada wrote:

> Hi,
>
> At Wed, 18 Oct 2006 00:01:11 +0900,
> Rick DeNatale wrote in [ruby-core:09218]:
>> One little quirk I just noticed is that String#lines seems to ignore a
>> block argument.
>> irb(main):002:0> "abc\ndef".lines {|l| puts l}
>> => #<Enumerable::Enumerator:0xb7cec20c>
>>
>> This is at odds with what the various each methods do:
>> irb(main):003:0> (1..3).each
>> => #<Enumerable::Enumerator:0xb7ce39e0>
>> irb(main):004:0> (1..3).each {|num| puts num}
>> 1
>> 2
>> 3
>> => 1..3
>
> /each.*/ !~ "lines".
>
> Or, lines is just an alias of each_line.

What's the best way to get an array of lines or bytes from a string in
1.9?  (I think this might help me get more of a grasp of the cases
where an Enumerator is returned.)


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