1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
func laughOutLoud(input: String, numOfTimes: Int, completion: (_ result: String) -> Void) { print ("start of function") print ("We are to display \(input) \(numOfTimes) times") for i in 0 ..< numOfTimes { print("\(input) number \(i)") } completion("Finished laughing!") print ("end of function") } laughOutLoud(input: "HA ", numOfTimes: 10) { (result) in //variable result is what is spit back out to us print ("start of the completion handler") print ("the result from the laughOutLoud is: \(result)") print ("end of the completion handler") } |