How does Ruby method lookup work? 🤔

Rémi Mercier - Nov 15 '19 - - Dev Community

Salut people!

I'm in the process of writing a beginners' introduction to Ruby classes and objects (18th Nov update: it's live!).

While talking with a friend about how classes inherit from their ancestors and the parent Class class, we realized we didn't know how exactly the method lookup works in Ruby.

My first (and wild) guess was: Ruby uses the method(:some_method).owner then check the ancestors' chain. But can't really wrap my head around this.

Anyone around here would like to have a go? 🙏

. . . . . . . . . . . . . . .
Terabox Video Player