Method access in Ruby
问题 How is it that Ruby allows a class access methods outside of the class implicitly? Example: class Candy def land homer end end def homer puts "Hello" end Candy.new.land #Outputs Hello 回答1: The definition of the "homer" method is adding the method to the Object class. It is not defining a free function. Class Candy implicitly inherits from Object, and so has access to the methods in Object. When you call "homer" in the "land" method, the method resolution can't find a definition in the current