From: 7stud -- Date: 2009-10-14T12:25:59+09:00 Subject: Re: no Enumerator#[] ? > Doesn't it seem reasonable for this to exist? Well this is ruby...so add away! unknown wrote: > 2009/10/14 trans > >> > > from C:/installs/ruby191p243p2/bin/irb:12:in `
' >> > if you want to get one or two first elements from Enumerator (or other > Enumerables), you can call > Enumerable#take > > "ab\r\nc".lines.take(1) => ["ab\r\n"] > "ab\r\nc".lines.take(2) => ["ab\r\n", "c"] ...or results = "ab\ncde\nfgh".lines.first(2) -- Posted via http://www.ruby-forum.com/.