From: "Florian Groß" Date: 2005-06-18T10:06:22+09:00 Subject: Re: What's the correspond method of PERL's DESTROY in ruby Timothy Hunter wrote: > Generally speaking there is no equivalent. Like Perl, Ruby's garbage > collection cleans up unreferenced objects without any intervention. If > you want do something to clean up an external resource at the point when > you're finished using the instance, the cooresponding Ruby idiom is to > use a block. Check out http://www.rubygarden.org/ruby?RubyIdioms. There is ObjectSpace.define_finalizer(obj) { ... }, but it should generally be avoided as there is trouble when the block references the object and that it is usually bad practice. Using free callbacks in C extensions makes sense, but if you find yourself using destructors in Ruby you are usually doing something odd.