From: Joel VanderWerf Date: 2005-12-13T06:13:19+09:00 Subject: Re: new to Ruby - pls help in translating this Chad Perrin wrote: ... > I don't see any particular reason to regard "ARGF.each do |elem|" as > better than "while gets", though. The latter of the two is more like "ARGF.each do |elem|" has two advantages: (1) easier to modify to use a different iteration method, such as map or grep. (2) easier to modify to use a different kind of enumerable, like an array or string, rather than a file or a duck-file like ARGF. (1) and (2) mean that code written using "ARGF.each do |elem|" can more easily be abstracted/refactored into library code. Of course, if you are writing a one-liner... Also, I prefer being explicit about the variable elem, rather than using $_, but that's me. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407