Look at MyC.ancestors:
=> [MyC, T1, S1, Object, Kernel, BasicObject]
so the super() in MyC#initialize calls T1#initialize. Then super() in
T1#initialize will call S1#initialize. If you call super() in
S1#initialize, it would call Object#initialize, and so on up the
ancestor chain.
ยทยทยท
On Thu, Mar 21, 2013 at 9:27 AM, Eugeni Kurtov <lists@ruby-forum.com> wrote:
===
module S1
def initialize
puts 's1'
end
end
module T1
def initialize
puts 't1'
end
endclass MyC
include S1
include T1
def initialize
puts 'myc'
super()
end
endMyC.new
output
myc
t1so, I can't call all the chain of initialize() of all included modules
in MyC ?and
====
module S1
def initialize
puts 's1'
end
end
module T1
def initialize
puts 't1'
super()
end
endclass MyC
include S1
include T1
def initialize
puts 'myc'
super()
end
endMyC.new
output
myc
t1
s1how's that super() in T1 calls initialize() in S1 ???
--
Posted via http://www.ruby-forum.com/\.