From: Zellyn Hunter Date: 2003-06-19T09:17:48+09:00 Subject: Class variables in parent and child classes with the same name Am I misunderstanding something, or can you not give a child class a class variable with the same name as a parent class? Just curious. It seems to work as one would expect for constants, but obviously one couldn't use a constant to keep track of information. [Note that ruby -w catches the redefinition] Zellyn class Parent Version = 1 @@count = 1 def printCount puts @@count end def printVersion puts Version end end class Child < Parent Version = 2 @@count = 2 def showCount puts @@count end def showVersion puts Version end end p = Parent.new c = Child.new c.printCount # => 2 c.showCount # => 2 p.printCount # => 2 c.printVersion # => 1 c.showVersion # => 2 p.printVersion # => 1