From: "Damián M. González" Date: 2012-09-16T16:16:06+09:00 Subject: Re: Class variables or Class singleton variables? Josh Cheek wrote in post #1076199: > The instance variable solution is better, I advocate never using class > variables for the reason that you showed. Agree with you as with Jan. > Singletons tend to force you into a workflow that you will later regret. > In this example, it's of course overkill, but for something with more > complex behaviour, try to get it where you can deal with it outside of > the constraints of the singleton (e.g. to test it or to use it in a > different way than imagined). Nice to know it. > Also, since I don't know what you're doing with it, let me warn against > tracking all the instances in some collection. This will prevent them > from > being garbage collected, and will prevent you from being able to create > instances where that is not the case (e.g. when you subclass pretty much > anything in Rails, it tracks that and then does things with it that you > may > reasonably want it to not do). Do you mean that is good to track all the instances of a class in some collection? Is not clear.. -- Posted via http://www.ruby-forum.com/.