Skip to content

Instantly share code, notes, and snippets.

@es-kumagai
Created January 15, 2023 07:52
Show Gist options
  • Save es-kumagai/6ce57484d6db09a4a2d3e03515ca9b2b to your computer and use it in GitHub Desktop.
Save es-kumagai/6ce57484d6db09a4a2d3e03515ca9b2b to your computer and use it in GitHub Desktop.
当然とも言えそうだけれど、シャドーイングする前に defer を仕掛けておけば、隠された側の後始末も普通に可能そうね。 #CodePiece
var value: Int? = 100
do {
defer {
value = nil
}
let value = value.map { $0 * 2 } ?? 0
print(value)
}
print(value?.description ?? "nil") // "nil"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment