Unable to overload function in viewDidLoad() in swift

后端 未结 2 1329
野趣味
野趣味 2021-01-22 08:18

Unable to overload function in viewDidLoad() in swift. It gives error definition conflict with previous value\" at \"func joinString(#strings: String...) ->

2条回答
  •  野的像风
    2021-01-22 09:02

    You can't overload in this way:

    func joinString(#strings: String[]) -> String {
     ...
    }
    func joinString(#strings: String...) -> String {
        ...
    }
    

    The joinString functions actually have same signature. Both take Array but the signature of the variadic version causes the compiler to generate with Array using the passed arguments at the call site.

提交回复
热议问题