Last active
August 18, 2020 15:01
-
-
Save sisoje/14c2a6fe2ac7521785cc2d6f7d00206e to your computer and use it in GitHub Desktop.
Resource acquisition is initialization (RAII) in Swift: Implementation
This file contains hidden or 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
class DeinitBlock { | |
let onDeinit: () -> Void | |
init(_ block: @escaping () -> Void) { | |
onDeinit = block | |
} | |
deinit { | |
onDeinit() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment