I've seen this code on the Swift site and various posts here and I am trying to grasp the basics. How is this line evaluated?
if let name = optionalName {
I'm confused as it's not name == optional name, it's assigning the value, so how does that report true and
why is it not true when you replace with john appleseed with nil, as its still going to be equal?
var optionalName: String? = "John Appleseed"
var greeting = "Hello!"
if let name = optionalName {
greeting = "Hello, (name)"
}
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…