4 ms·
This is a good introduction to ruby's method lookup, even if it isn't fully accurate. The author notes that he hasn't read the ruby source code, and his explan
by jeremyevans 13y ago
This is a good introduction to ruby's method lookup, even if it isn't fully accurate. The author notes that he hasn't read the ruby source code, and his explanation is "just a model you can use to understand things."
While mostly accurate, his description of the module hierachy as a tree leads to a wrong understanding of how ruby's method lookup actually works. If ruby did use a tree, then including module B in module A after including module A in class C would result B being one of C's ancestors, which isn't the case. Ruby's method lookup uses a linked list (not a tree) using iclasses for modules (a pseudo-copy of the module, which is why later includes have no effect). However, a description of that may be too in-depth for an introduction.