我如何列出Ruby中不是内置方法的对象的所有方法,如果执行Fruit.new.methods,它将列出所有方法,其中包括在类Fruit中声明的用户定义方法,我想只看到在Fruit类中编写的方法。
myFruit.public_methods(false)
返回myFruit
可访问的公共方法列表,但不包括继承的方法。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.