【发布时间】:2011-03-11 14:44:39
【问题描述】:
鉴于此代码:
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' 定义,但我不知道如何使用。有什么想法吗?
问候
汤姆
【问题讨论】:
标签: ruby class inheritance constants