简体   繁体   中英

How do I call a Clojure function that takes a two-dimensional array of Strings from Java?

Basically question says it all.

When I declare a function signature in gen-class, what type do I put for a 2D array of strings?

[myFunc [XXXX] ReturnType]

what do I put for XXXX?

Update : following @Mark Topolnik's suggestion, I'm trying

#^{:static true} [myFunc [ ^"[[Ljava.lang.String;" ] clojure.lang.IFn] 

in my declaration, and I'm getting back a

java.lang.RuntimeException: Unmatched delimiter: ]

runtime exception when I try to compile it.

Update 2 : Fixed by removing the ^ from the above line. (This is in the context of declaring function signatures in a gen-class so that ^ is presumably unnecessary.)

Multidimensional array types have no direct support in Clojure, but you can always fall back to using a String with the binary type name. In your case, this would look like the following:

[myFunc ["[[Ljava.lang.String;"] ReturnType]

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