gpt4 book ai didi

arrays - Swift 数组行为

转载 作者:搜寻专家 更新时间:2023-10-30 22:16:44 25 4
gpt4 key购买 nike

在 Swift 中数组有一个特殊的行为,但为什么这里 arr1 包含两次“item 1”而 arr2 只包含一次?

在这里将 arr1 定义为实例变量有什么变化(相对于将 arr2 定义为局部变量)?

更新:我正在使用 Xcode 6.0.1

enter image description here

最佳答案

我可以在 Xcode 6.0.1 中可靠地重现这个结果:

Xcode 6.0.1

但在 Xcode 6.1 GM 中没有:

Xcode 6.1

看起来这是一个已修复的错误。

作为临时解决方法,这适用于 Xcode 6.0.1:

Workaround

关于arrays - Swift 数组行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26235785/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com