[#3986] Re: Principle of least effort -- another Ruby virtue. — Andrew Hunt <andy@...>

> Principle of Least Effort.

14 messages 2000/07/14

[#4043] What are you using Ruby for? — Dave Thomas <Dave@...>

16 messages 2000/07/16

[#4139] Facilitating Ruby self-propagation with the rig-it autopolymorph application. — Conrad Schneiker <schneik@...>

Hi,

11 messages 2000/07/20

[ruby-talk:03830] Re: Order of overwriting

From: Dave Thomas <Dave@...>
Date: 2000-07-05 14:49:41 UTC
List: ruby-talk #3830
Aleksi Niemel<aleksi.niemela@cinnober.com> writes:

> This works probably just as it should, but I'm just curious why I expect
> declarations to overwrite each other in the order they're written, instead
> of "whaa, we have a class declaration here, let's see if we have to include
> any modules before defining new, possibly overwriting, methods"?

That's not quite what's happening (although it looks that way).

When you include a module in a class, you've affectively making that
module a parent of the class[1]. As such, it gets inserted between the
class and the class' original parent:

      Bar  -->  Zak

   "include Foo"

      Bar  -->  Foo --> Zak

   "include Foo_update"

      Bar  -->  Foo_update --> Foo --> Zak

So your call will result in zak, foo, foo_update, bar, which indeed it 
does.


Regards


Dave

Footnotes: 
[1]  In reality you're making a proxy for the module a parent. This
allows the same module to appear in many different inheritance
chains.



In This Thread

Prev Next