Last active
August 29, 2015 14:23
-
-
Save AlexanderNey/c076f7a0f60b7be11074 to your computer and use it in GitHub Desktop.
ARTICLE Function Composing Swift 2.0 - 3
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
func combine <A,B,C>(first: A throws -> B, _ second: B throws -> C) -> (A throws -> C) { | |
return { (parameter: A) throws -> C in | |
let finalResult = try second(first(parameter)) | |
return finalResult | |
} | |
} | |
let data = //... the NSData representing the json | |
let parseAndValidate = combine(parseJSONFromNSData, validateJSONResponse) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment