Where is the methods method defined?

Hi,

just curious where can I find definition of methods method ?

BasicObject.method(:methods).owner

=> Kernel

BasicObject.ancestors

=> [BasicObject] # ?? it does not inherit from Kernel class ??

BasicObject.method(:methods).source_location

=> nil

That looks inconsistent. Possible bug ?
ruby 1.9.3p327

···

--
Posted via http://www.ruby-forum.com/.

you are currently asking for the method of the class BasicObject.

BasicObject.singleton_class.ancestors
=> [Class, Module, Object, Kernel, BasicObject]

···

--
Posted via http://www.ruby-forum.com/.

Thanks for the replies. It's defined, a bit counter-intuitively, in
class.c.

···

--
Posted via http://www.ruby-forum.com/.

Hans Mackowiak wrote in post #1092344:

you are currently asking for the method of the class BasicObject.

BasicObject.singleton_class.ancestors
=> [Class, Module, Object, Kernel, BasicObject]

Ok, that would explain 'methods' method really comes from Kernel but
what about its definition ? For example at
http://www.ruby-doc.org/core-1.9.3/Kernel.html is not listed between
Kernel class methods.

···

--
Posted via http://www.ruby-forum.com/.

It is probably just a bit confused because the method definition is located in class.c, not object.c. I dunno tho.

···

On Jan 15, 2013, at 04:36 , David Unric <lists@ruby-forum.com> wrote:

Hans Mackowiak wrote in post #1092344:

you are currently asking for the method of the class BasicObject.

BasicObject.singleton_class.ancestors
=> [Class, Module, Object, Kernel, BasicObject]

Ok, that would explain 'methods' method really comes from Kernel but
what about its definition ? For example at
http://www.ruby-doc.org/core-1.9.3/Kernel.html is not listed between
Kernel class methods.

Ok, that would explain 'methods' method really comes from Kernel but
what about its definition ? For example at
http://www.ruby-doc.org/core-1.9.3/Kernel.html is not listed between
Kernel class methods.

http://ruby-doc.org/core-1.9.3/Object.html#method-i-methods

James

It does come from Kernel module.
See https://github.com/ruby/ruby/blob/ruby_1_9_3/object.c#L2706

···

On Friday, 18 January 2013 г. at 5:54, James Britt wrote:

>
> Ok, that would explain 'methods' method really comes from Kernel but
> what about its definition ? For example at
> http://www.ruby-doc.org/core-1.9.3/Kernel.html is not listed between
> Kernel class methods.

http://ruby-doc.org/core-1.9.3/Object.html#method-i-methods

James