Skip to content

Instantly share code, notes, and snippets.

@damianesteban
Created August 27, 2015 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damianesteban/ee599b310c9dd11e96a7 to your computer and use it in GitHub Desktop.
Save damianesteban/ee599b310c9dd11e96a7 to your computer and use it in GitHub Desktop.
Test for Superman in Swift 2
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