On Sun, Dec 4, 2011 at 1:47 PM, Mc Ben <viertelvor12 / gmx.net> wrote:
> On Ruby 1.9.3 (win7(64))
>
> Because code says more the thousand words:
> ##################
> open("test.txt","r").each do end # doesn't close file
> FileUtils.rm "test.txt"      # will fail: Permission denied
> ##################
> (it doesn't matter if the "do end" is filled or omitted)
>
> Bug, 'Feature' or my mistake?

open will only close if you pass it a block directly.

open('test.txt'){|file| file.each{ ... } }


-- 
Michael Fellinger
CTO, The Rubyists, LLC