【发布时间】:2017-05-31 13:59:44
【问题描述】:
我有一个类似下面的函数,它是由脚本自动生成的。
def printFunc(args : Any*) : Unit = {
funcCallHandler.call(args)
}
funcCallHandler 中的调用函数如下所示。该函数也从其他生成的函数中获取可变参数。
def call(args : Any*) : Unit = {
for (arg <- args) {
/*Check type using a match function
and add do the rest of the code*/
}
}
当我将从第一个函数获得的变量参数传递给第二个提到的函数时,我将它作为 WrappedArray。有没有办法输入匹配这个 WrappedArray 或者有更好的方法吗?
第一个函数的情况下不指定类型。
【问题讨论】:
-
@DavisBroda
args本身是一个可变参数这一事实是不同的信息,可能会令人困惑(尽管解决方案确实相同)。 -
funcCallHandler.call(args:_*)
标签: scala