小编Jim*_*ire的帖子

更改为 Swift 3 后发生变异操作符错误,问题已研究,但无法解决

我收到“变异运算符的左侧不可变”..<“返回不可变值”错误

我阅读了关于变异值的另一篇文章,但我无法弄清楚这些解决方案是如何应用的。

代码(和评论):

 //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
}
Run Code Online (Sandbox Code Playgroud)

修订代码:

 //populate array of 3 random numbers using correct answer and 2 incorrect choices …
Run Code Online (Sandbox Code Playgroud)

mutable operator-keyword swift3 xcode8

5
推荐指数
1
解决办法
6036
查看次数

标签 统计

mutable ×1

operator-keyword ×1

swift3 ×1

xcode8 ×1