How can I call parents constructor ?
module C
attr_accessor :c, :cc
def initialization c, cc
@c, @cc = c, cc
end
end
class B
attr_accessor :b, :bb
def initialization b, bb
@b, @bb = b, bb
end
end
class A < B
include C
attr_accessor :a, :aa
def initialization (a, b, c, aa, bb, cc)
#call B::initialization - ?
#call C::initialization - ?
@a, @aa = a, aa
end
end
Thanks.
First, your method should be
initialize, notinitialization. Then, you can usesuperto call the parent class method. As for callingC‘s initializer inA, for clarity, I’d recommend splitting the initialization stuff into a different function, then just calling that function directly. It’s easy to implement, and clearer.