From: Albert Schlef Date: 2010-02-05T20:50:36+09:00 Subject: Re: Some noob questions Robert Klemme wrote: > On 05.02.2010 00:10, Albert Schlef wrote: >> Robert Klemme wrote: >>> File.foreach(file).each_slice 2 do |name, pwd| >> >> How is it better than 'File.open(file).each_slice' ? > > It closes the file handle properly which your variant doesn't do. You mean, that in my version the file isn't closed till the file object gets destroyed by the garbage collector? I see. (I assume the enumerator returned by foreach() mimics foreach()'s behaviour; that is, that it closes the file after the last iteration.) -- Posted via http://www.ruby-forum.com/.