[英]ruby: how to get all the methods that are defined or overwrited in current class rather than base class?
有誰能獲得在當前類而不是基類中定義或覆蓋的所有方法? 例如
class MyBase
def Test
end
end
class MyDerived
def Test1
end
end
當我調用MyDerived.methods時,我有很多方法,但是我只想獲取'Test1',因為它是它自己的方法,可以嗎? 謝謝。
class Foo
def bar
end
end
Foo.new.public_methods false
=> [:bar]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.