Last active
November 2, 2015 05:08
-
-
Save rsmoz/647e93e6cae07caa20d7 to your computer and use it in GitHub Desktop.
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
public enum Producer<A> { | |
case Value(A) | |
case Error(ErrorType) | |
func produce() throws -> A { | |
switch self { | |
case let .Value(x): | |
return x | |
case let .Error(y): | |
throw y | |
} | |
} | |
} | |
//Signature in method | |
func getActionable(resultCallback: (Producer<Image> -> Void)) | |
//Use | |
do { | |
self.image = try res.produce() | |
self.updateContent() | |
} | |
catch { | |
print("Image unavailable") | |
//Set error image | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment