Am I going crazy ? (optional param with completion)

No idea if this is a bug if not why is it happening ? ...


static func writeJSON(_ url: URL,_ array: [Array],_ completion: ((_ success: Bool,_ error: String) -> Void)?)


Doing this works fine but ...


static func writeJSON(_ url: URL,_ array: [Array]? = nil,_ completion: ((_ success: Bool,_ error: String) -> Void)?)


Doesn't work ? Yet optional Parameters without the optional Completion work fine, just not both together.

Accepted Reply

AFAIU, you should better not not have a _ to mute the external label.


May look at this: https://stackoverflow.com/questions/24102925/swift-function-with-default-parameter-before-non-default-parameter

Replies

Sorry didn't post all the info. Had a play around and figured there were too many optional omitted parameters.

AFAIU, you should better not not have a _ to mute the external label.


May look at this: https://stackoverflow.com/questions/24102925/swift-function-with-default-parameter-before-non-default-parameter

Both of your code compile without any issues if I replaced `Array` to some existing type.


Please provide an example which can reproduce the issue. Or the issue is solved in your mind?

It's fine now thanks, as I added the mention above I overloaded it with too many Omited Parameters.