Created
June 27, 2018 03:32
-
-
Save aainaj/6c86edc7a297e8ed4de2f97b0870d825 to your computer and use it in GitHub Desktop.
Closure CaptureList
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - Closures | |
import Foundation | |
class CaptureList: NSObject { | |
let digit = 5 | |
override init() { | |
super.init() | |
makeSquareOfValue { [digit] squareDigit in | |
print("Square of \(digit) is \(squareDigit)") | |
} | |
} | |
func makeSquareOfValue(onCompletion: (Int) -> Void) { | |
let squareDigit = digit * digit | |
onCompletion(squareDigit) | |
} | |
} | |
CaptureList() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment