Swift - Assigning Overloaded Function to Variable

后端 未结 5 543
走了就别回头了
走了就别回头了 2021-01-05 07:52

I am getting a compile time error that myFunc reference is ambiguous.

func f (s: String) -> String { return \"version 1: \" + s }
func f(sourceString s: S         


        
5条回答
  •  梦谈多话
    2021-01-05 08:06

    I don't think you can. You can call one or the other:

    println(f("test")) // version 1: test
    println(f(sourceString: "test")) // version 2: test
    

提交回复
热议问题