如题
当我把 module B 及 C extendi 后
有没有方法拆掉 module C
谢谢
module B
def name
"B" + super
end
end
module C
def name
"C" + super
end
end
class A
def name
"A"
end
end
if __FILE__ == $0
a= A.new
puts a.name #=> "A"
puts a.singleton_class.ancestors # => [#<Class:#<A>0x00007fffd913a138>>, B, A, Object, PP::ObjectMixin, Kernel, BasicObject]
a.extend(B)
puts a.name # => "BA"
puts a.singleton_class.ancestors # => [#<Class:#<A>0x00007fffd913a138>>, B, A, Object, PP::ObjectMixin, Kernel, BasicObject]
a.extend(C)
puts a.name # => "CBA"
puts a.singleton_class.ancestors # => [#<Class:#<A>0x00007fffd913a138>> ,C, B, A, Object, PP::ObjectMixin, Kernel, BasicObject]
end