7
A
回答
8
看起来在Groovy格外漂亮(未经测试,taken from this link所以代码信贷应该去那里):
// Introspection, know all the details about classes :
// List all constructors of a class
String.constructors.each{println it}
// List all interfaces implemented by a class
String.interfaces.each{println it}
// List all methods offered by a class
String.methods.each{println it}
// Just list the methods names
String.methods.name
// Get the fields of an object (with their values)
d = new Date()
d.properties.each{println it}
你正在寻找的总称是内省。
4
如上所述here,找到字符串对象定义的所有方法:
"foo".metaClass.methods*.name.sort().unique()
它并不像Python版本那样简单,也许别人可以表现出更好的办法。
0
相关问题
- 1. 什么是Groovy等同于Python的dir()的无参数版本?
- 2. 等价于python“dir”的Java?
- 3. 什么是'configure --prefix = DIR && make all install'的nmake等价物?
- 4. 什么是Python的os.walk的等价物?
- 5. Python的dir(object)和__builtin__等价于Julia
- 6. 什么是java.util.zip.Inflater的Python等价物?
- 7. 什么是Python os.pathsep的等价物?
- 8. python中'gem'的等价物是什么?
- 9. Python中imadjust的等价物是什么?
- 10. 什么是Tomcat的Python等价物?
- 11. python中print_r()的等价物是什么?
- 12. Python中perluniprops的等价性是什么?
- 13. Python`itertools.chain`的Ruby等价物是什么?
- 14. 什么是Perlbrew的Python等价物?
- 15. dir是什么? dir +“/”:“”是什么意思?
- 16. rssplit()与re.split()是什么等价的?
- 17. 与AngularJS $ routeChangeStart等价的Angular2是什么?
- 18. python dir()在JavaScript中等价吗?
- 19. 什么是C++的积累或Groovy注入的Java等价物?
- 20. Windows上的os.fork()与Python的等价性是什么?
- 21. Elixir中是否有Python的dir()的等价形式
- 22. 什么是等价类?
- 23. 与org.eclipse.jdt.core.IJavaElement等效的Python/PyDev是什么?
- 24. 什么是“tar cf results.tar -C dir1/dir2 dir-to-zip”的7z或zip等价物?
- 25. Python 2中字母Python 3的等价性是什么?
- 26. 从R到Python,什么是数据框的python等价物?
- 27. Python中的“require”(Ruby)等价于什么?
- 28. JavaScript是否与Python的__getattribute__等价吗?
- 29. 什么是Twisted Python的Lua等价物,Ruby的Eventmachine,Java的NIO等等?
- 30. 什么是PHP的preg_quote的等价物?
谢谢你提供这个词! – WilliamShatner