I read and tried the documentation, everything is clear, but not so in practice. Task: subtract another from one number using closures.
@IBAction func buttonLikePressed(sender: UIButton) { calculateLikes(50, newLikes: 1, operation:{$0 - $1}) } func calculateLikes(currentLikes:Int, newLikes: Int, operation: (Int, Int) -> Int) -> Int { return operation (currentLikes, newLikes) } I looked in the debugger, the line
calculateLikes(50, newLikes: 1, operation:{$0 - $1}) It is called, but what it does is not clear. The result of the function = 50, not 49, as expected.
return currentLikes-newLikes- Max Mikheyenko