相关疑难解决方法(0)

隐式解包可选使不可变

为什么我不能改变一个隐式解包的可选变量?

以下是重现问题的简短示例:

使用Array

var list: [Int]! = [1]
list.append(10) // Error here
Run Code Online (Sandbox Code Playgroud)

Immutable value of type '[Int]' only has mutating members named 'append'

用Int

var number: Int! = 1
number = 2
number = 2 + number
number += 2 // Error here
Run Code Online (Sandbox Code Playgroud)

Could not find an overload for '+=' that accepts the supplied arguments

swift

10
推荐指数
2
解决办法
4086
查看次数

标签 统计

swift ×1