I'm trying to define a type alias for a closure in swift 3 like that:
public typealias URLRequestClosure = (response: URLResponse?, data: Data?, error: Error?) -> Void
I get an error that I'm supposed to put underscore before the parameters' names. i.e:
public typealias URLRequestClosure = (_ response: URLResponse?, _ data: Data?, _ error: Error?) -> Void
can anyone explain me why? Is it something to do with Swift 3?
Thanks a lot
You can't specify parameter names in closure typealias. So instead of:
public typealias URLRequestClosure = (response: URLResponse?, data: Data?, error: Error?) -> Void
You should use:
public typealias URLRequestClosure = (URLResponse?, Data?, Error?) -> Void
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With