问题
I am trying to create two methods with the following arguments but the compiler is complaining that they are ambiguous. I am following a youtube series to learn Swift and it seems to be fine in the video there. What am I missing?
func performOperation(operation: Double -> Double){
func performOperation(operation:(Double, Double)->Double){
回答1:
It seems you may be running into the same problem mentioned in this reddit thread. It looks like the solution may just be to rename your functions, due to a clash with inherited with Objective C methods.
e.g.
func myPerformOperation(operation: Double -> Double){
func myPerformOperation(operation:(Double, Double)->Double){
(These aren't ideal names—they should be more descriptive—but you get the idea.)
来源:https://stackoverflow.com/questions/32687503/function-overloading-in-swift