Satisfy one of multiple constraints using switch
suggest changeMatch a tuple of optionals. Swift 2 spelled the case .Some. Swift 3 and later use .some.
let str: String? = "hi"
let x: Int? = 5
switch (str, x) {
case (.some, .some):
print("Both have values")
case (.some, nil):
print("String has a value")
case (nil, .some):
print("Int has a value")
case (nil, nil):
print("Neither has a value")
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents