From: "Iñaki Baz Castillo" Date: 2011-08-15T03:40:38+09:00 Subject: Re: class inheritance and class constants 2011/8/14 Chris White : > This behavior can fortunately be overridden by simply overriding the hello method in the B class, meaning that it will use the constant defined in B instead Yes, but it requires duplicating code. In my case I've a server class: class Server def self.foo puts "I listen in IP #{IP}" end end and then some classes inhereting from it: class UdpServer < Server IP = "1.2.3.4" end class TcpServer < Server IP = "1.2.3.5" end Of course "TcpServer.foo" fails: NameError: uninitialized constant Server::IP So I must use workarounds like: class Server def self.foo puts "I listen in IP #{self::IP}" end end class UdpServer < Server IP = "1.2.3.4" end class TcpServer < Server IP = "1.2.3.5" end Then it works: TcpServer.foo => I listen in IP 1.2.3.5 UdpServer.foo => I listen in IP 1.2.3.4 -- Iñaki Baz Castillo