From: gabriele renzi Date: 2005-04-13T03:44:38+09:00 Subject: Re: ability to run finalizers at a given point of a program? Guillaume Cottenceau ha scritto: > In other words, in my opinion there are cases where IO can be freed > with a try|begin/catch|rescue/finally|ensure but other cases where for > example an object is a wrapper around some IO, and in such > circumstances it makes good sense to free this IO when the object it > out of scope instead of explicitely calling a close/free method, > especially when there can be several locations of your program that > make use of such an object. I think you misunderstood slightly the precious message. In ruby, whenever you want this kind of "create & use & destroy quickly" idiom, you don't call a free/close method explicitly, you rely on methods that handle it for you, say: open('file') do |f| bla bla end it is the #open call that cares of freeing the resource, there is no need to handle it by yourself. In java you don't have blocks, so you have to always use "finally".