On Apr 16, 2007, at 4:02 AM, noreply / rubyforge.org wrote:
> Category: Core
> Group: 1.8.4
> Status: Open
> Resolution: None
> Priority: 3
> Submitted By: Lance Ivy (cainlevy)
> Assigned to: Nobody (None)
> Summary: class variables and inheritance
>
> Initial Comment:
> The unexpected behavior is shown in this script:

Class variables are lexically scoped.  This means that @@foo
in your example is resolved with respect to the class/end block
that contains the reference and not relative to self when foo
executes.  In your example, @@foo is always associated with the
class A.  Despite the syntactic similarity (@@ vs @), class
variables have entirely different semantics than instance variables.

As Adam Bozanich suggested, class instance variables have the
semantics that you are looking for.



Gary Wright