Posts Tagged ‘class variable’

It is not chrismas, hence no quiz, but this was strangely surprising:

class A
@@t = "A::@@t"
T="A::T"

def self.s1; @@t; end
def self.s2; T; end
end

class B < A
def self.s1; @@t; end
def self.s2; T; end
end

class C < A
@@t = "C::@@t"
T="C::T"
def self.s1; @@t; [...]