在下面的示例中,我希望在实例化B
时创建/设置类中的实例变量B
。显然我不想去重新initialize
定义A
.
class A
def initialize(a)
end
def initialize(a, b)
end
end
class B < A
# Here I want an instance variable created without
# redefining the initialize methods
@iv = "hey" #<-- Obviously does not work
# And I don't want to have to do @iv |= "hey" all over the place
end