最佳答案
我在 Swift 网站上看到过这段代码,在这里看到过各种各样的帖子,我正试图掌握这些基础知识。如何计算这条线?
if let name = optionalName {
我很困惑,因为它不是 name = = 可选的 name,而是赋值,那么如何报告 true 和 为什么它不是真的,当你用零代替约翰苹果种子,因为它仍然是相等的?
var optionalName: String? = "John Appleseed"
var greeting = "Hello!"
if let name = optionalName {
greeting = "Hello, \(name)"
}