Anton Kazennikov
Anton Kazennikov

Reputation: 3604

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?

Upvotes: 13

Views: 1368

Answers (2)

Hubert Fonseca
Hubert Fonseca

Reputation: 41

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.

Upvotes: 4

kotarak
kotarak

Reputation: 17299

Try

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

Upvotes: 14

Related Questions