[Frank Sonnemans]
> Does Ruby have a destructor as in C++?

Not like that in C++. Since Ruby frees all memory automatic through its
garbage collection, it does not need destructors.

You can use ObjectSpace.define_finalizer to define a method that will be called
when an object is garbage collected. That is somewhat similar to a destructor,
but note that there can be a long delay between your last use of the object and
the start of garbage collection -- that may not be what you want.

In some cases, it is better to define a method that does what you want
(i.e. File.close) than to do it automatically in a finalizer.

// Niklas