加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xcode – Swift playground打印括号

发布时间:2020-12-14 17:13:32 所属栏目:百科 来源:网络整理
导读:Xcode 7.2,Swift 2.0: 下面的代码在调试区域中打
Xcode 7.2,Swift 2.0:
下面的代码在调试区域中打印“15()”.我原以为它打印“15 1”.为什么要打印括号?

var n = 15
print(n,n /= 10)

解决方法

因为赋值运算符没有返回任何内容.
它仍然执行.

请参阅此处的文档:Swift Docs

The assignment operator (=) does not return a value,to prevent it from being mistakenly used when the equal to operator (==) is intended.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读