我有一个接受String*
参数的函数。我正在实现另一个函数,该函数需要Seq[String]
(或字符串数组)作为参数,但需要使用该参数调用先前的函数。有什么办法可以进行转换吗?
def foo (s: String*) = {
...
}
def callFoo (s: Seq[String]) = {
foo (s) // this throws an error
}
Run Code Online (Sandbox Code Playgroud)
foo
函数可以称为foo("string1", "string2", "string3")
。但是我只想调用callFoo(Seq[String])
函数并从中获取结果foo()