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