本帖最后由 guoxiaomi 于 2021-5-5 22:36 编辑
https://bparanj.gitbooks.io/ruby ... he_main_object.html
The methods defined at the top level becomes private method in the Object. This shows that these methods are bound to the main object.
def function666(x);end p method(:function666) #=> #<Method: main.function666> p method(:function666).owner #=> Object p self.private_methods.include?(:function666) #=> true p Object.private_methods.include?(:function666) #=> true
def function666(x);end
p method(:function666) #=> #<Method: main.function666>
p method(:function666).owner #=> Object
p self.private_methods.include?(:function666) #=> true
p Object.private_methods.include?(:function666) #=> true
|