Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 4 issue with #61

Closed
LalitKY opened this issue Oct 17, 2017 · 4 comments
Closed

Swift 4 issue with #61

LalitKY opened this issue Oct 17, 2017 · 4 comments

Comments

@LalitKY
Copy link

LalitKY commented Oct 17, 2017

In below two functions

/**
get typed Array of JSONJoy and have it throw if it doesn't work
*/
public func get<T: JSONJoy>() throws -> [T] {
guard let a = getOptionalArray() else { throw JSONError.wrongType }
return try a.reduce(T) { $0.0 + [try T($0.1)] }
}

/**
 get typed `Array` and have it throw if it doesn't work
 */
open func get<T: JSONBasicType>() throws -> [T] {
    guard let a = getOptionalArray() else { throw JSONError.wrongType }
    return try a.reduce([T]()) { $0.0 + [try $0.1.get()] }
}

In below two return values

return try a.reduce(T) { $0.0 + [try T($0.1)] }
return try a.reduce(T) { $0.0 + [try $0.1.get()] }

Error = "Contextual type for closure argument list expects 1 argument, but 2 were specified".

Update your code respectively.

@freddyKang
Copy link

i have same problem.......

@bohdanPaliychuk
Copy link

the same issue, do you how to fix it ?

@Asuard
Copy link
Contributor

Asuard commented Nov 8, 2017

Hello,

I have sent a PR (#63) to fix this issue.

daltoniam added a commit that referenced this issue Nov 8, 2017
Fix reduce closure for Swift 4
@daltoniam
Copy link
Owner

Thanks @Asuard. Version 3.0.3 has been released with the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants