Created
December 15, 2014 21:56
-
-
Save he9lin/4f9b947cf558d6d1ba06 to your computer and use it in GitHub Desktop.
Succinct Result enum for handling requests
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
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