Im having trouble in swift using nested functions and variadic inputs. the following function returns an error saying it can not convert type [int] to to expected int the mathFunction has the same input type as defined and given. Do I need to do any sort of converion?
func printResults(_ mathFunction: (Int...) -> Double, _ a: Int...) {
print("Results \(mathFunction(a))")
}
In your example,
a
is an[Int]
.[Int]
cannot (yet) be passed into a closure (mathFunction
) expectingInt...
.There's a ticket open for this, which you can see here: [SR-128] Pass array to variadic function