From: trans Date: 2009-10-14T08:17:32+09:00 Subject: Re: no Enumerator#[] ? On Oct 13, 6:03 pm, Patrick Okui wrote: > On Oct 14, 2009, at 12:49 AM, Roger Pack wrote: > > > Currently > > >>> "ab\r\nc".lines[0] > > NoMethodError: undefined method `[]' for # > >        from (irb):1 > >        from C:/installs/ruby191p243p2/bin/irb:12:in `
' > > > Doesn't it seem reasonable for this to exist? > > Try "ab\r\nc".lines.to_a[0]. Perhaps it does. Why should it have to convert the whole enumerable to an array, if it only needs to calculate 0..index? Of course, it might be very inefficient to keep asking for lines that way, nonetheless... ?