From: Robert Klemme Date: 2005-09-10T21:56:35+09:00 Subject: Re: method_added for class methods David A. Black wrote: > Hi -- > > On Sat, 10 Sep 2005, Trans wrote: > >> class X >> class << self >> def method_added(*args) >> p args >> end >> def singletin_method_added(*args) > > s/tin/ton/ :-) > >> p args >> end >> end >> end > > I believe that only the singleton_method_added actually does anything. > I guess that's because the only methods you can add to this class are > singletons, and that gets priority. > > At least, when I tried method_added, I couldn't get any output. Worksforme: >> class Bar >> class <> def x() end >> end :x => nil >> >> Don't ask me to explain it --it's mind numbing. > > Like so many things, it comes down to: > > * objects can have singleton methods > * singleton methods are stored in the object's singleton class > * classes are objects > > It's so lovely, don't you think? :-) Yes! Kind regards robert