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