Last active
July 19, 2016 14:14
-
-
Save ezura/bd16fc09e9711ed195672b25788bc59c to your computer and use it in GitHub Desktop.
こんな感じで、使うまでに初期化されていることが保証できる + defer = 最後までに絶対に値が決まることが保証できる #swift #CodePiece
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
func sample() { | |
let constValue: String | |
// error: constant 'constValue' used before being initialized | |
defer { | |
print(constValue) | |
} | |
// constValue = "" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment