From: "Aleksi Niemelä" Date: 2000-07-05T17:58:22+02:00 Subject: [ruby-talk:03835] Re: Order of overwriting > A> Now I just have to give some time for my mental model to > A> adjust. It just got > not really Thank you! I have to remember this little creature: > pigeon% ruby -Dtx b.rb It's the Ruby's dynamic nature which is teasing me :). My mental model seems to be ok. Now it's time to adapt it to feel well with the real environment. In that environment Ruby does class Foo < Bar # Foo.parents.unshift Bar def foo # Foo.add_method foo [1] end include "Zak" # Foo.parents.unshift Zak end [1] here I assumed to be Foo#foo.super=Foo.parents[0] so when Ruby tries to find a proper method it asks for Foo#foo.super (which is pointing to Bar#foo). This was my mistake. Actually the (dynamic) model seems to be def Foo#foo.super Foo.parents[0]#foo end so the lookup is done dynamically each time. And for performance purposes Ruby might cache the actual value for Foo#foo.super, and each 'include' importing the method of same name just updates the cached value. Anyway, it's probably better to start think in dynamic terms :). Thanks for Guy and Dave for interesting and enlightening explanation. - Aleksi