Mic*_*ael 3 clojure clojure-java-interop
我在某处看到过这个文档,但我不记得函数的名称和名称:我正在搜索的是一个函数/宏,它以(Java)对象作为参数,在该对象上执行一系列方法,然后返回它。类似的东西:
(<the function> obj
(.setName obj "the name")
(.setAmount obj42.0)
; ...
(.setDescription obj "the description")) ; returns the updated obj
Run Code Online (Sandbox Code Playgroud)
您可以使用..:
(.. obj (setName "the name") (setAmount 42.0) ... (setDescription "the description"))
Run Code Online (Sandbox Code Playgroud)
如果这些方法不返回目标对象,您可以使用doto:
(doto obj (.setName "the name") (.setAmount 42.0) ... (.setDescription "the description"))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
78 次 |
| 最近记录: |