From: "Wolfgang Nádasi-Donner" Date: 2007-01-21T00:20:11+09:00 Subject: Re: Minor Change Proposal for Classes 'Object' and 'Method' Vincent Fourmond schrieb: > gwtmp01@mac.com wrote: >> Method#receiver >> Method#name >> Method#origin # module/class with definition of method >> >> Kernel#origin(name) # module/class where named method is found >> # via standard method lookup process on the >> # receiver. >> # nil if no matching method found > > I vote for the last one too ! > > Vince An additional method "Kernel#origin(name)" will be helpful, if the method is defined as a singleton method for an object, it is difficult to get the object_id of the anonymous class, where the method ist defined (I hope this sentense is somehow understndable). The object_id is necessary in comparisons with the result of the call to the method of class "Method", that returns the associated class. Here is some code as an example for the problem (if I didn't make some conceptional errors): class Otto end p Otto # => Otto puts "%x" % Otto.object_id # => 1574ecc otto = Otto.new puts "%x" % otto.object_id # => 1574d96 class < #> puts "%x" % self.object_id # => 1574d78 def hi puts "'Hi!' from 'otto'" end end p otto.class # => Otto puts "%x" % otto.class.object_id # => 1574ecc p otto.class.superclass # => Object puts "%x" % otto.class.superclass.object_id # => 15386b6 myottohi = otto.method(:hi) myottohi[] # => 'Hi!' from 'otto' p myottohi # => #.hi> Wolfgang N�dasi-Donner