Luke De Feo
Luke De Feo

Reputation: 2165

Confusing closure usage in swift constructor

I was looking at the source code for promise kit as i want to extend it but i was puzzled by this initialiser

public init(@noescape resolvers: (fulfill: (T) -> Void, reject: (ErrorType) -> Void) throws -> Void) { }

In particular

resolvers: (fulfill: (T) -> Void, reject: (ErrorType) -> Void) 

It seems to be two arguments in the constructor indicated by the comma inbetween each closure signature except there is one arguement label called resolvers and the brackets span the two closures... What is this?

In my specific use case i want to extend this initialiser in a subclass where my customer initialiser adds a third closure which the subclass retains but pass the other two to super.

Upvotes: 2

Views: 100

Answers (1)

Access Denied
Access Denied

Reputation: 9461

resolvers is a tuple with two lamdas. For more info take a look here: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html

Upvotes: 2

Related Questions