Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialOguzhan Cetinkaya
2,172 PointsHere is my latest answer for task 2: let difference = mathOperation(differenceBetweenNumbers,3,5) What is the problem?
I cannot pass the exam. What's wrong?
func differenceBetweenNumbers(a: Int, b:Int) -> (Int) {
return a - b
}
// Enter your code below
func mathOperation(aFunc:(Int, Int) -> (Int),firstInt:Int,secondInt:Int) -> (Int){
return aFunc(firstInt,secondInt)
}
let difference = mathOperation(differenceBetweenNumbers,3,5)
2 Answers
Caleb Kleveter
Treehouse Moderator 37,862 PointsUse this code for the function, gets rid of some of the parentheses around the returns:
func mathOperation(anyAddFunc: (Int, Int) -> Int, a: Int, b: Int) -> Int{
return anyAddFunc(a,b)
Caleb Kleveter
Treehouse Moderator 37,862 PointsI don't know that this code is any different but try copy and pasting it.
let difference = mathOperation(differenceBetweenNumbers, 2, 1)
Oguzhan Cetinkaya
2,172 PointsUnfortunately, it did not work. I cannot pass the Swift Closure exam because of this problem.
Oguzhan Cetinkaya
2,172 PointsOguzhan Cetinkaya
2,172 PointsThank you, it worked :) It's about the compiler and some empty spaces issue I think..
Caleb Kleveter
Treehouse Moderator 37,862 PointsCaleb Kleveter
Treehouse Moderator 37,862 PointsGlad you passed, happy coding!