While testing performance of redis these days, I need to use mset() interface of jedis (a java version redis client). But the prototype of mset() in jedis is:

  public String mset(final String... keysvalues) {

Firstly I write my scala code like:

var array = Array[String]()
array = array:+key1:+value1
array = array:+key2:+value2

But it report compiling errors:

[error] xxx: overloaded method value mset with alternatives:
[error]   (x$1: String*)String 
[error]   (x$1: Array[Byte]*)String
[error]  cannot be applied to (Array[String])
[error]                                 jedis.mset(array)
[error]                                       ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 4 s, completed Jan 8, 2016 11:32:47 AM

After searching many documents about scala/java on google, I finally find the answer: http://docs.scala-lang.org/style/types.html. So, let’s write code this way:


Then Array[String] of scala changes to varargs in java now. It also viable for Seq[String].