【发布时间】:2012-07-03 14:43:53
【问题描述】:
我有一颗宝石,其中一个类是相似的:
class Test
TESTING = {
:sth1 => 'foo',
:sth2 => 'bar'
}
# p Test.new.show
# should print 'cat'
def show
p TESTING[:sth3]
end
end
我在其他文件中扩展
# in other file
class Test
TESTING = {
:sth3 => 'cat'
}
end
但我需要在第一个文件中使用 :sth3,因为代码的第一部分代表。 提前谢谢。
【问题讨论】:
标签: ruby-on-rails ruby inheritance constants