From: peter.meier998@... Date: 2009-04-29T02:05:06+09:00 Subject: Re: Opposite of initialize Thanks. Exacalty what I need. Haven't seen it. On Apr 28, 5:55 pm, Eleanor McHugh wrote: > On 28 Apr 2009, at 17:45, peter.meier...@gmail.com wrote: > > > I'm looking for the opposite function of initialize() as I need to > > call something before an object is "destroyed". > > ObjectSpace#define_finalizer allows you to have a proc executed when   > an object is about to be destroyed. If I remember rightly this is when   > the object is actually garbage collected, which can be some time after   > all its references have been released. > > Ellie > > Eleanor McHugh > Games With Brainshttp://slides.games-with-brains.net > ---- > raise ArgumentError unless @reality.responds_to? :reason