简体   繁体   English

Clojure中的“长数字”参数等效吗?

[英]What's the equivalent of “long… numbers” params in Clojure?

I'm trying to call this java method from Clojure and it's throwing me "ClassCastException Cannot cast java.lang.Long to [J java.lang.Class.cast (Class.java:3003)" 我试图从Clojure调用此java方法,并抛出“ ClassCastException无法将java.lang.Long强制转换为[J java.lang.Class.cast(Class.java:3003)”)

public String encrypt(long... numbers) {
  return encode(numbers, alphabet_, salt_, minHashLength_);
}

What's the equivalent of calling that method from Clojure? 从Clojure调用该方法相当于什么?

Java varargs are syntactic sugar that compiles down to a single array argument. Java varargs是语法糖,可以编译为单个数组参数。 In order to pass data from Clojure into this method, convert your collection of longs to an array with the long-array function. 为了将Clojure中的数据传递给此方法,请使用long-array函数将long的集合转换long-array

(.encrypt obj (long-array [1 2 3]))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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