J
Jez Stephens
Hi,
I want to be able to keep track of all instances of a class using
something simple like this:
Class Thing
@@allthings = []
def initialize
@@allthings.push self
end
end
However an obvious drawback to this approach is that instances of this
class will never be garbage collected due to the reference held in
@@allthings.
Is there a way to make it so this reference in @@allthings "doesn't
count", so to speak?
Or is there a better way of doing it?
Thanks for your help
I want to be able to keep track of all instances of a class using
something simple like this:
Class Thing
@@allthings = []
def initialize
@@allthings.push self
end
end
However an obvious drawback to this approach is that instances of this
class will never be garbage collected due to the reference held in
@@allthings.
Is there a way to make it so this reference in @@allthings "doesn't
count", so to speak?
Or is there a better way of doing it?
Thanks for your help