class Thing
@cache = {}
def self.instance(name)
@cache[name] ||= new(name)
end
def initialize(name)
@name = name
end
end
t1 = Thing.instance "t"
t2 = Thing.instance "t"
p t1.id
p t2.id
[rolo] mysterious. it works! but since cache is an instance level variable how is it shared amongst all the class instances?
rolo