From: Wejn Date: 2002-07-12T19:29:39+09:00 Subject: Destructors in Ruby Hi all, I have following class: class Foo def initialize @locked = false end def lock return if @locked # Set up exclusive-write lock @locked = true end def do_something raise RuntimeError, "Not locked" unless @locked # Do something if locked end def unlock return unless @locked # Free that lock @locked = false end end Is there any way I can ensure that 'unlock' will be called at the end of instance lifetime (before GC will purge it out of mem)? I need this feature because I can't leave the external resource locked and I can't trust to other code to release (unlock) it correctly. Thanks in advance, W. -- Wejn (svamberk.net's Linux section, fi.muni.cz student, linuxfan) >>> Bored? Want hours of entertainment? <<< >>> Just set the initdefault to 6! <<<