Skip to content

Instantly share code, notes, and snippets.

@rsmoz
Last active November 2, 2015 05:08
Show Gist options
  • Save rsmoz/647e93e6cae07caa20d7 to your computer and use it in GitHub Desktop.
Save rsmoz/647e93e6cae07caa20d7 to your computer and use it in GitHub Desktop.
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