我不太明白为什么我不能将Int []从一个函数传递到另一个函数:
func sumOf(numbers: Int...) -> Int {
var sum = 0
for number in numbers {
sum += number
}
return sum
}
func average(numbers:Int...) -> Double {
var sum = sumOf(numbers)
return Double(sum) / Double(numbers.count)
}
Run Code Online (Sandbox Code Playgroud)
这给了我以下错误:
Playground execution failed: error: <REPL>:138:19: error: could not find an overload for '__conversion' that accepts the supplied arguments
var sum = sumOf(numbers)
^~~~~~~~~~~~~~
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!