Skip to content

Instantly share code, notes, and snippets.

@delba
Created June 10, 2015 11:26
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 delba/877c5ccd3f1b6b558e4e to your computer and use it in GitHub Desktop.
Save delba/877c5ccd3f1b6b558e4e to your computer and use it in GitHub Desktop.
switch tupple
typealias Result = (value: String?, error: String?)
let result = Result("value", nil)
switch result {
case let (.Some(value), .None):
print(value)
case let (.None, .Some(error)):
print(error)
case let (.Some(value), .None(error)):
print(value, error)
case let (.None, .None):
break
}
switch result {
case let (.Some(value), _):
print(value)
case let (_, .Some(error)):
print(error)
default:
break
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment