From: ahoward@... (ara howard) Date: 2002-09-24T02:59:04+09:00 Subject: Re: alias/method redfinition ts wrote in message news:... so, in general, extending an object always results in a new proxy class being created as the first one to be searched in the inheritence hierarchy, and because mutiply extending an object with a module would result in duplicate classes being created in the inheritence tree ruby protects against this by not allowing 'extend M' to happen more than once? -a > a> this works. though i do not understand how the super remains bound to > a> the old [] after the call 'extend M' > > The new methods #[] and #[]= are created in the module M and they don't > erase the old definitions which are in the class Hash > > When you write > > extend M > > ruby will create a proxy class which is inserted just before the class > Hash, this will give a class (and methods) specific to this object > > When you call #[] (#[]=) for this object, ruby find these methods in the > proxy class, and with a call to #super ruby will retrieve the methods > stored in Hash > > You have something like this > * before extend, the inheritance for the object is > > Hash ==> [Enumerable] ==> Object ==> [Kernel] > > * after extend for this same object > > (singleton class) ==> [M] ==> Hash ==> [Enumerable] ==> Object ==> [Kernel] > > [M] is a proxy class to M > [Enumerable] is a proxy class to Enumerable