本文介绍了Python“dir”等价于Clojure的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人知道如果有一个Clojure等价于Pythonsdir。基本上我需要知道的功能,我可以调用的东西或更具体的java对象我想知道的方法和属性可用(我不知道如果在java他们被称为方法和属性,这是C#lingo)。
解决方案
clojure.contrib.repl- utils / show
:
user => (使用'[clojure.contrib.repl-utils:only(show)])
nil
user => (show String)
=== public final java.lang.String ===
[0] static CASE_INSENSITIVE_ORDER:Comparator
[1] static copyValueOf:String(char [])
[2] static copyValueOf:String(char [],int,int)
[3] static format:String(Locale,String,Object [ String,Object [])
...
p>
user => (map#(。getName%)(.getMethods String))
(equalstoStringhashCodecompareTo...)
.getFields
和 .getConstructors
p>
Does anybody know if there is a Clojure equivalent for Pythons "dir". Basically I need to know the functions I can call on something or more specifically for java objects I want to know the methods and properties available (I am not sure if in java they are called methods and properties, this is C# lingo).
解决方案
clojure.contrib.repl-utils/show
for use at the REPL:
user=> (use '[clojure.contrib.repl-utils :only (show)])
nil
user=> (show String)
=== public final java.lang.String ===
[ 0] static CASE_INSENSITIVE_ORDER : Comparator
[ 1] static copyValueOf : String (char[])
[ 2] static copyValueOf : String (char[],int,int)
[ 3] static format : String (Locale,String,Object[])
[ 4] static format : String (String,Object[])
...
Alternatively, maybe something like:
user=> (map #(.getName %) (.getMethods String))
("equals" "toString" "hashCode" "compareTo" ...)
.getFields
, and .getConstructors
accordingly.
这篇关于Python“dir”等价于Clojure的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!