鉴于此代码:
class A CONST = 'A' def initialize puts CONST end end class B < A CONST = 'B' end A.new # => 'A' B.new # => 'A'
我想B使用这个CONST = 'B'定义,但我不知道如何.有任何想法吗?
B
CONST = 'B'
问候
汤姆
ruby inheritance class constants
class ×1
constants ×1
inheritance ×1
ruby ×1