Declare array as return type in gen-class method declaration in Clojure

巧了我就是萌 提交于 2019-12-31 21:33:15

问题


How to declare an array in method declaration in gen-class?

(ns foo.bar
(:gen-class
 :methods [[parseString [String Object] Object]]))

That works fine. But the return type is really an array. How I can declare that so Java can understand it?


回答1:


Try

(ns foo.bar
  (:gen-class
    :methods [[parseString [String Object] "[Ljava.lang.Object;"]]))



回答2:


I needed a

static Number[][] method(int, Number[][]);

signature, in a similar way:

(:gen-class
:methods [#^{:static true} [method [int "[[Ljava.lang.Number;"] "[[Ljava.lang.Number;"]])

seemed to work.



来源:https://stackoverflow.com/questions/2398478/declare-array-as-return-type-in-gen-class-method-declaration-in-clojure

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!