From: Joel VanderWerf Date: 2011-12-05T11:47:18+09:00 Subject: Re: 'open().each' doesn't close file On 12/04/2011 06:27 PM, Dave Aronson wrote: > On Sun, Dec 4, 2011 at 08:19, Michael Fellinger wrote: >> On Sun, Dec 4, 2011 at 1:47 PM, Mc Ben wrote: > ... >>> open("test.txt","r").each do end # doesn't close file >>> FileUtils.rm "test.txt" # will fail: Permission denied > ... >> open will only close if you pass it a block directly. >> >> open('test.txt'){|file| file.each{ ... } } > > So just "do end" doesn't count as a block? Seems (at least to me) > like it should, albeit not usually a very useful one.... In your case, the "do end" block is passed to the #each call, not to the #open call.