0
我有一個像下面這樣的函數,它由腳本自動生成。將「Any *」變量參數傳遞給需要「Any *」的另一個函數
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或者有更好的方法來做這件事?
該類型沒有在第一個功能的情況下指定。
[如何將scala數組傳遞到scala可變參數方法?](https://stackoverflow.com/questions/31064753/how-to-pass-scala-array-into-scala-vararg-method) –
@DavisBroda'args'本身就是一個可變參數,這是一個不同的信息,可能會讓人困惑(儘管解決方案確實是一樣的)。 –
'funcCallHandler.call(args:_ *)' – Dima