Created
August 27, 2015 15:29
-
-
Save damianesteban/ee599b310c9dd11e96a7 to your computer and use it in GitHub Desktop.
Test for Superman in Swift 2
This file contains 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
enum SuperManIdentityError: ErrorType { | |
case WrongSecretIdentityError | |
} | |
func isSuperManTest(testWithSecretIdentity secretIdentity: String) throws -> String { | |
if secretIdentity != "Clark Kent" { | |
throw SuperManIdentityError.WrongSecretIdentityError | |
} | |
return secretIdentity | |
} | |
do { | |
let secretIdentityTest = try isSuperManTest(testWithSecretIdentity: "Bruce Wayne") | |
} catch let error { | |
print("Wrong secret identity") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment