From: Eric Hodel Date: 2006-06-17T12:04:58+09:00 Subject: Re: cleanup, of sorts On Jun 16, 2006, at 7:26 PM, Tom Allison wrote: > Is there a method equivelant to perls DESTROY? > > I'm trying to clean up database connections that I created with an > object instantiation but how to I make certain that they are closed > when the object is out of scope? If the DB library writer did their job (and I'm sure they did), they just are by the GC provided there are no references to them. Typically you see code like this when you want to ensure cleanup: class IO def open(filename, mode) io = new filename, mode if block_given? then begin yield ensure io.close unless io.closed? end end return io end end -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com