Hi
I’m sorry I found out the reason is that the method is not a class method.
Sorry for being ignorant.
Shannon
···
From: “Shannon Fang” xrfang@hotmail.com
Reply-To: ruby-talk@ruby-lang.org
To: ruby-talk@ruby-lang.org (ruby-talk ML)
Subject: Reflection?
Date: Wed, 4 Dec 2002 01:16:26 +0900Hi,
Pls have a look at the following code:
class A
def mymethod
p “I am A!”
end
end
p A.ancestors
p A.respond_to?(“mymethod”)
p A.methods.sortIt will give out all methods in the ancestor classes, but no A! and
A.respond_to?(“mymethod”) will return false…Tks.
Shannon
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail
Add photos to your messages with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail