swift variadic nested function

158 views Asked by At

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))")
}
1

There are 1 answers

0
Alexander On

In your example, a is an [Int]. [Int] cannot (yet) be passed into a closure (mathFunction) expecting Int....

There's a ticket open for this, which you can see here: [SR-128] Pass array to variadic function