On Jun 28, 2006, at 1:13 PM, Jonas P. wrote:
Modules are inserted into the inheritance chain. So if you do
a = A.new
a.x (Look for #x in my singleton class, can’t find it? Ok, look for
it in A, aha! found it! return “x”)
b = B.new
b.x (Look for #x in my singleton class, can’t find it? Ok, look for
it in B, can’t find it? Ok, look for it in X, aha! found it return “y”)
As you can see, it doesn’t really have anything to do with the fact
that it’s a singleton class, it’s just how modules work.
The reason why using #extend can override something declared in an
objects class is because the singleton class is earlier in the
inheritance chain than the actual class of the object. extend
includes the module into the singleton class which puts it earlier
than the object’s real class.