From: matz@... (Yukihiro Matsumoto) Date: 2002-02-08T01:23:56+09:00 Subject: Re: Class variable bug Hi, In message "Class variable bug" on 02/02/08, "Chr. Rippel" writes: |It seems that the following class variable bug feel through the |reporting cracks - the problem is that the two different class method |definition styles potentially effect the visibility of class variables |in conjunction with mixins in subclasses. First of all, if you put '-v' option to the interpeter, it warns you about class variables, that means it might not work as you expected. Second of all, the behavior difference comes from structure difference, i.e. |class A | class << self | def first_form; @@var end | end |end In this case "@@var" is a class variable of surrounding class (unnamed singleton class attached to A), whereas |class A | def A.first_form; @@var end |end "@@var" is a class variable of surrounding class (A). This behavior difference is arguable. Since "class << self" form can be considered as short hand of singleton methods definitions, you can say it is better to have same behavior to singleton methods. It can be implemented by simply removing one line from eval.c. I'm open to discussion. matz.