Created
June 23, 2016 21:14
-
-
Save rileytestut/56981c48f1dd5eb1b00effdac9e04472 to your computer and use it in GitHub Desktop.
Swift Tuple Casting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let string1: NSObject = NSString(string: "string1") | |
let string2: NSObject = NSString(string: "string2") | |
if let result = (string1, string2) as? (NSString, NSString) | |
{ | |
print(result) | |
} | |
else | |
{ | |
print("Failure") | |
} | |
// Prints: Failure | |
if let result = (string1, string2) as? (NSObject, NSObject) | |
{ | |
print(result) | |
} | |
else | |
{ | |
print("Failure") | |
} | |
// Prints: (string1, string2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment