[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

_id2ref in finalize or how get object.var from class.finalize

andrey

12/15/2007 4:55:00 PM

#!/usr/bin/ruby1.8

include ObjectSpace

class MyClass
attr_reader :var
def initialize(var)
@var = var
puts "from initialize: #{@var}"
define_finalizer(self, self.class.method(:finalize).to_proc)
end

def MyClass.finalize(object_id)
o = _id2ref(object_id)
puts "from finalize: #{o.var}"
end
end # class Storage

o = MyClass.new("The Value!")
exit 0

Hi, all.

Why lines of a code after a call of function "_id2ref(object_id)" are
never carried out?
How it is possible to get access to variables or methods of a object
from a method of a class :finalize?