From: Bill Kelly Date: 2002-11-25T02:04:07+09:00 Subject: Re: Ruby idom needed From: "ts" < > >>>>> "B" == Bill Kelly writes: > > >> h = Hash[*File.new("fred.ini").read.split(/=|\n/)] > > B> I like the above, but wondered it it leaves the file open? > > The file will be closed when it will be garbage collected. You again!!!! ;-D Hehe... Intriuging. It's indeed good to learn GC will cause the file to be closed (makes sense.) I don't know if I worry too much, but that does set off my potential- danger-alarm meter a bit, depending on conceivable circumstances: for instance, if the above were in a loop. Would it be possible to run out of file handles before GC was called? If so, I would personally find myself resistant to adopting the idiom of letting GC close file handles, as I would view the relationship between the opener of the handles, and GC, as a potential race condition lurking in my code. . . . But it could be I worry too much. :) Regards, Bill