2
我有一個非常簡單的問題,我無法找到答案。我試圖通過一個方程來插入一個x和y值的數組,並用答案填充一個數組。此代碼中的錯誤是數組不接受數字,因爲「錯誤:'範圍'不能轉換爲'詮釋'」。我將如何處理這個?這是在快速操場上用Xcode 6.01完成的。謝謝!使用For循環變量在Swift中選擇數組項目
let x = [5.0,2.0,43.0,1.0,5.0]
let y = [62.0,2.0,43.0,1.0,4.0]
var answers=[Double]()
var current:Double = 0
for numbers in [0...4] {
current = 1800*x[numbers] + 1600*y[numbers]
answers.append(current)
}
println(answers)
謝謝,這有助於一噸。 – CarveDrone 2014-10-08 19:06:49