here is the Swift 3 version of Challenge Closure for printNumbersInReverse:
var printNumbersInReverse: ([Int]) β Void = {(numbers: [Int]) β Void in
for number in numbers.reversed(){
print(number)
}
}
In the solution playground the printNumbersInReverse closure should have the following in line 38:
print(numbers[counter-index])
Otherwise the output is not reversed.
Thanks for the heads up β¦ Iβve updated the files with the correct solution.
In the example of the trailing enclosure in the video (at 03:59), itβs got this as the original form of the enclosure:
operateOnNumbers(10, 5, operation: { $0 * $1 })
β and this as the trailing enclosure:
operateOnNumbers(10, 5) {
$0 + $1
}
Is that addition operator in the trailing enclosure a typographical error? Should it be a multiplication operator?
guru
7
Hi Brian in video at (3:49) you have written
operateOnNumbers(10, 5, operation: { $0 * $1 })
Can you please tell , how to use it in a playground as playground is not accepting this code.
arvnq
9
func operateOnNumbers(_ a: Int, _ b: Int, operation:(Int, Int) β Int) {
operation(a, b)
}