From: "Peña, Botp" Date: 2003-07-09T18:55:30+09:00 Subject: Re: Array.each Brian Candler [mailto:B.Candler@pobox.com] wrote: > # what follows are just testing > x = '(1..8).to_a.each_group {|x,y,z| p "x = #{x}; y = > #{y.inspect}; z = > #{z.inspect}"}' > > Why did you include "to_a"? Enumerable works on iterators > without having to convert them to an explicit array first. > For example, you could have a file with a million lines and > process it three lines at a time using lol :-)) pls forgive me. As a nuby, I thought (1..8) was _just_ a range, so I converted it to array first. I'm still thinking/seeing things narrowly. Thank you for pointing me to enumerables & iterators. > File.open("/name/of/file").each_group {|l1,l2,l3| puts > "<#{l1}:#{l2}>#{l3}"} > > If you did "to_a" it would have to read in the whole file > into RAM first. very good point and very helpful indeed. > Regards, > > Brian. kind regards -botp >