[TxMt] TODO List
Sune Foldager
cryo at cyanite.org
Sat Feb 25 11:13:47 UTC 2006
On 25/02/2006, at 10:58, Soryu wrote:
> Apparently I do open all the files to scan them but do not close
> them afterwards. D'oh!
> This should now be fixed.
Whenever possibly, use the 'auto-dispose' way of obtaining such
resources, like
File.open(filename) do |f|
..the code..
end
which will close the file regardless of how the block is left
(normally, 'return', exceptins, throw etc.)
Alternatively, use 'ensure' which is really what the above is:
begin
f = File.open(...)
...
ensure
f.close
end
(Oh and I didn't look at your code before writing this, so apologies
if it's all old news).
-- Sune.
More information about the textmate
mailing list