如何在Scala中对此进行编码?
def myFun(strings: String*) = {
// do something...
}
def myWraper(strings: String*) = {
// do something else and then call myFun with the dame input
myFun(strings)
}
我尝试过像
这样的星号def myWraper(strings: String*) = {
// do something else and then call myFun with the dame input
myFun(strings*)
}
但这似乎不起作用......
答案 0 :(得分:11)
试试这个:
myFun(strings: _*)
你需要告诉它在varargs上分割strings
。