// Playground - noun: a place where people can play
func getAverage(numbers: Int...) -> Double{
var total = 0
var average:Double = 0
for number in numbers{
total = total + number
}
average = total / numbers.count
return average
}
getAverage(3, 6)
我收到一个错误average = total / numbers.count
找不到接受提供的参数的“/”的重载
我试图通过这样做来解决:
average = Double(total/numbers.count)
但后来 getAverage 被设置为4
而不是4.5