How method look up works in Ruby? : From what I read, the method look up works scanning the object's class, and scanning for any method defined there. If it's not found there, we keep moving the hierarchial chain until we find it.

It makes sense for this:

    Class A
      def hello 
        p 'hello world'
      end
    end

    A.new.hello  

(hello is defined in A.new.class).

But it doesn't work like this when we call a method on Class object.


Eg:


    class A 
    
      def self.hello
        p 'hello world'
      end
    
    end

    A.hello

This should link A -> Eigen class with method `hello` -> Object --> BasicObject .. 

And how ruby find the method is by looking at object's class and then moving up the ladder.

So it should have looked the method at `A.class` which is `Class`, and never found the method `hello`?






