[英]Obtain direct instance methods defined on a class
I want to get all the methods that are defined directly on the class 我想获得直接在类上定义的所有方法
Here is what I currently do: 这是我目前做的事情:
class Mine
def immediate
end
(instance_methods - ancestors.second.instance_methods)
# [:immediate]
end
Is there a better way? 有没有更好的办法?
Mine.instance_methods false
does this look good? 这看起来不错吗? or how do you like to write it? 或者你觉得怎么写? something like Mine.my_instance_methods? 像Mine.my_instance_methods这样的东西? :) :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.