From: Hector Quiroz Date: 2012-01-27T01:04:10+09:00 Subject: Garbage collection I think this is a simple question but I just down't know where to find the answer. Any help would be appreciated. I have the following code: class MMR attr_accessor :id, :name, :cap @@header = [] def initHeader(fld) @@header = fld end def initInstance(fld, cap=0) @@header.each_with_index {|fn, i| send("#{fn}=", fld[i])} self end end MMR.new.initHeader(['id', 'name', 'cap']) # The above line instanciates an MMR object and initializes @@header. # My question is, since I don't have a variable pointing to this newly # instantiated MMR object, can it be removed by the garbage collector? # Is this dangerous? # When I run the program it works just fine but I'm afraid it may not @lst << MMR.new.initHeader(['1', 'disk1', '1073741824']) @lst << MMR.new.initHeader(['2', 'disk2', '10737418240']) Thanks Hector -- Posted via http://www.ruby-forum.com/.