Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 841
Anton Kazennikov Avatar asked Mar 07 '10 23:03

Anton Kazennikov


2 Answers

Try

(ns foo.bar
  (:gen-class
    :methods [[parseString [String Object] "[Ljava.lang.Object;"]]))
like image 141
kotarak Avatar answered Nov 16 '22 07:11

kotarak


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.

like image 28
Hubert Fonseca Avatar answered Nov 16 '22 05:11

Hubert Fonseca