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 trialKyaw Kyaw Soe
7,528 PointsI don't understand this challenge please give me answer or explain for me Please
I don't understand this challenge please give me answer or explain for me Please
2 Answers
Richard Lu
20,185 PointsHi Jo,
The challenge is to build a function that takes in an argument of a function type. The function called differenceBetweenNumbers, it takes 2 integers (Int, Int) and returns another integer (-> Int), and also 2 other integers that act as operands.
So they want a function that takes those types. How does someone approach this? Well it's simple, take a look below:
func mathOperation(operation: (Int, Int) -> (Int), operand1: Int, operand2: Int) -> Int {
return operation(operand1, operand2)
}
// Usage
let difference = mathOperation(differenceBetweenNumbers, 1, 2)
Hope I've helped. Happy Coding :)
Kyaw Kyaw Soe
7,528 PointsThank you so much Richard Lu. Your answer make me understanding very well