将可变长度参数传递给期望相同的另一个函数?

Iva*_*van 6 scala variadic-functions

如何在Scala中正确编码?

def myFun(strings: String*) = {
  // do something...
}

def myWraper(strings: String*) = {
  // do something else and then call myFun with the dame input
  myFun(strings)
}
Run Code Online (Sandbox Code Playgroud)

我试过像星号一样

def myWraper(strings: String*) = {
  // do something else and then call myFun with the dame input
  myFun(strings*)
}
Run Code Online (Sandbox Code Playgroud)

但这似乎不起作用......

dhg*_*dhg 11

试试这个:

 myFun(strings: _*)
Run Code Online (Sandbox Code Playgroud)

你需要告诉它分开stringsvarargs.