Where does "define_method" defined?

B

Brian Xue

[Note: parts of this message were removed to make it a legal post.]

Hello,

From Ruby library reference manual, It tells that "define_method" is an
instance method of "class Module < Object", but why the following call give
out "false"

Module.instance_methods.include? :define_method
=> false

Thanks,
Brian
 
Y

Y. NOBUOKA

Hi,

Yes, a +define_method+ method is an instance method of the +Module+ class,
as you said. However, the method is PRIVATE [1], so you can't find it by using
your code.
Please use following code instead.

(on ruby 1.9.2-p180)
Mocdule.private_instance_methods.include? :define_method
=> true

[1] http://ruby-doc.org/core/classes/Module.html#M000497

Regards,
 
B

Brian Xue

[Note: parts of this message were removed to make it a legal post.]

Thank you very much for you help.

Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top