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)
你需要告诉它分开strings
varargs.
归档时间: |
|
查看次数: |
1547 次 |
最近记录: |