2

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
  • 1
    You should probably post the actual error, not your interpretation of it Commented Dec 19, 2016 at 1:54

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.