【发布时间】:2011-07-19 12:53:31
【问题描述】:
在以下测试用例中:
class Package
class Component
def initialize
p [:initialize,self]
end
end
end
class Package_A < Package
end
class Package_B < Package
end
# Why are the following components of type Package and not Package_A and Package_B
component=Package_A::Component.new
p component
component=Package_B::Component.new
p component
结果:
[:initialize, #<Package::Component_1:0x2c0a8f8>]
#<Package::Component:0x2c0a8f8>
[:initialize, #<Package::Component_1:0x2c0a5b0>]
#<Package::Component:0x2c0a
如何获取特定的 Package_A.component 和 Package_B.component?
【问题讨论】:
标签: ruby inheritance nested-class