Let's say we have a function with defalut parameter values:
// function with default parameter values
func a(m:Int = 0, n:Int = 1) {
print(m, n)
}
a() // 0 1
a(m:2) // 2 1
a(n:3) // 0 3
a(m:4, n:5) // 4 5
Now I want to return exactly the same function from another function:
func b() -> (Int,Int)->Void {
func a(m:Int = 0, n:Int = 1) {
print(m, n)
}
return a // function returned
}
let a2 = b()
a2(m:4, n:5) // ⛔ error: extraneous argument labels 'm:n:'
a2(4) // ⛔ error: missing argument for parameter #2
a2(4,5) // OK
Now, neither can I use argument labels nor can I use default values for parameters, why?
It seems that function a2()
is a totally different thing from function a()
, what's going on behind the scenes?