From: Yukihiro Matsumoto Date: 2009-09-29T13:32:06+09:00 Subject: Re: Inconsistent behavior of singleton methods that access class variables: 1.8.7 vs 1.9.2 Hi, In message "Re: Inconsistent behavior of singleton methods that access class variables: 1.8.7 vs 1.9.2" on Mon, 28 Sep 2009 04:06:42 +0900, Nikolai Lugovoi writes: |So, the question is, what is the correct way to declare and use such |constructs, and what caused the problem -- bug in ruby or incorrect |use of class variables? The basic rules for class variables are: (1) initialize at class variables at the top of the scope (in this case, A). (2) avoid name conflict of class variables in the same top-level scope; in the case of the example, you used @@list several times in the scope of A. (3) and lastly, and most importantly, do not use class variables, unless you really really need them; they are fundamentally global variables. You've violated all of above rules. matz.