Skip to content

Instantly share code, notes, and snippets.

@he9lin
Created December 15, 2014 21:56
Show Gist options
  • Save he9lin/4f9b947cf558d6d1ba06 to your computer and use it in GitHub Desktop.
Save he9lin/4f9b947cf558d6d1ba06 to your computer and use it in GitHub Desktop.
Succinct Result enum for handling requests
enum Result<T> {
case Error(NSError)
case Value(T)
}
getUser(request) { result in
switch result {
case let .Error(error):
// display error message
case let .Value(user):
// do something with user
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment