From: "Damián M. González" Date: 2012-09-17T00:41:44+09:00 Subject: Re: Class variables or Class singleton variables? Josh Cheek wrote in post #1076220: > No, I'm saying don't do this. You can count dog legs since that's a > single > object, but don't implicitly try to track all of the dogs. Well but I don't see another way of keep track of the objects which I'll have to work around. I do this in many cases: class Foo @instances = [] #can be a Hash too, whatever class << self attr_accessor :instances end attr_accessor :nickname initialize(nickname) @nickname = nickname Foo.instances = Foo.instances.push(self) end end Do you say that I do not have to do this? How can I keep track of the instances so, if I want to refer them in the future? 'cause later meaby I'll need to do this: Foo.instances.each do |x| puts x.nickname end -- Posted via http://www.ruby-forum.com/.