を解決することはできません「演算子を変異の左側には変更できません」.. <「不変の値を返します」というエラー変異オペレータのエラー、問題を研究し、私は取得しています
私が読んでもう1つの値は突然変異に関するものですが、その解決策がどのように適用されるかはわかりません。
コード(とコメント):
//populate array of 3 random numbers using correct answer and 2 incorrect choices
func insertIntoArray3(_ randomNumber: Int) -> Int {
for intJ in 0 ..< 2 += 1{
if arrayIndex != 3 {
checkIfExists(randomNumber)
if ifExists {
let randomNumber = 1 + random() % 10
insertIntoArray3(randomNumber)
} else {
array3[arrayIndex] = (randomNumber)
arrayIndex = arrayIndex + 1
}
}
}
return randomNumber
}
改訂コード:
//populate array of 3 random numbers using correct answer and 2 incorrect choices
func insertIntoArray3(_ randomNumber: Int) -> Int {
for _ in 0 ..< 2 + 1{
if arrayIndex != 3 {
checkIfExists(randomNumber)
if ifExists {
let randomNumber = 1 + arc4random() % 10
insertIntoArray3(Int(randomNumber))
} else {
array3[arrayIndex] = (randomNumber)
arrayIndex = arrayIndex + 1
}
}
}
return randomNumber
}
ありがとうございました!
私はここでも同じエラーを取得しています....
//this function populates an array of the 40 image names
func populateAllImagesArray() {
for intIA in 1 ..< 11 += 1 {
tempImageName = ("\(intIA)")
imageArray.append(tempImageName)
tempImageName = ("\(intIA)a")
imageArray.append(tempImageName)
tempImageName = ("\(intIA)b")
imageArray.append(tempImageName)
tempImageName = ("\(intIA)c")
imageArray.append(tempImageName)
}
//println("imageArray: \(imageArray) ")
//println(imageArray.count)
}
改訂:
//this function populates an array of the 40 image names
func populateAllImagesArray() {
for intIA in 1 ..< 11 + 1 {
tempImageName = ("\(intIA)")
imageArray.append(tempImageName)
tempImageName = ("\(intIA)a")
imageArray.append(tempImageName)
tempImageName = ("\(intIA)b")
imageArray.append(tempImageName)
tempImageName = ("\(intIA)c")
imageArray.append(tempImageName)
}
//println("imageArray: \(imageArray) ")
//println(imageArray.count)
}
ありがとうございました!
'for intIA in 1 .. <11 + = 1'ここで '+ = 1'は間違っています。 –