简体   繁体   中英

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

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?

Try

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM