From: Jim Weirich Date: 2003-05-21T11:46:51+09:00 Subject: Re: An Object Going Out Of Scope On Tue, 2003-05-20 at 16:14, MikkelFJ wrote: > > "Jim Weirich" wrote in message > > auto(foo=MyObject.new, :cleanup) do > > # use foo > > end > > fine if you can handle multiple objects this way. Mauricios suggestion does > that, but does not allow you to specify cleanup method. This, of course can > be done in many ways. The syntax is not a big deal. One idea is to allow "auto" to take a list of variables. Here's another idea that's more general approach (although a bit more verbose ...) auto_block do |closer| a = closer.register(Thing.new) { |thing| thing.close } b = closer.register(Stuff.new) { |x| x.shut_down } # do stuff with a & b... end # closer will close anything registered with it. -- -- Jim Weirich jweirich@one.net http://jimweirich.umlcoop.net --------------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)