我认为这是可能的,但似乎无法让它发挥作用。我敢肯定我只是愚蠢。我试图以以下形式输出格式化地址
"one, two, three"
来自一组可选组件(一个、两个、三个)。如果 "two" 为 nil,则输出为
"one, three"
let one: String?
let two: String?
let three: String?
one = "one"
two = nil
three = "three"
if let one = one,
two = two,
three = three {
print("\(one),\(two),\(three)")
}