gpt4 book ai didi

swift - Optionals 默认为 nil 吗?

转载 作者:行者123 更新时间:2023-11-28 11:00:17 25 4
gpt4 key购买 nike

如果没有提供构造函数,delegate 变量的初始值是多少?

class Example {
weak var delegate: Bool?
}

最佳答案

是的,如果未分配,它会自动设置为 nil。

来自 Apple :

If you define an optional variable without providing a default value, the variable is automatically set to nil for you

关于swift - Optionals 默认为 nil 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40907002/

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