返回首页 - Notes - 2016

Ruby 继承链


module M1
end

module M2
end

module M3
end

module M4
end

class Hello
  include M1
  include M2

  # This is the position of class self

  prepend M3
  prepend M4
end

p Hello.ancestors
# M4, M3, Hello, M2, M1, Object, Kernel, BasicObject

列出类继承链的技巧:


date:2016-08-19