From: "David A. Black" Date: 2005-06-27T04:56:39+09:00 Subject: Re: Defining a method vs aliasing it Hi -- On Sun, 26 Jun 2005 gwtmp01@mac.com wrote: > > On Jun 25, 2005, at 7:33 AM, leon breedt wrote: >> I'm not exactly sure why defining a method with "def methodname" >> versus aliasing it would behave differently. > > It is my understanding that 'alias' doesn't behave in the sense that > it creates two method names that reference the same definition. Instead > it creates a new method and duplicates the definition of the old message. > The resulting method is completely independent of the original method. > > Maybe I'm missing something (probably) but there seems to be a semantic > mismatch between the word 'alias' and the behavior of the method 'alias'. > > Shouldn't it be called dup_method or something similar? I believe it's the other way around: aliasing a method name just adds another name for the same method. If you then redefine the original method, the two names then point to different methods: class C def x; end alias :y :x # y and x are the same method def x; "new method"; end # they are not the same end At least that's always been my understanding of it. David -- David A. Black dblack@wobblini.net