Skip to content

Instantly share code, notes, and snippets.

@ezura
Last active July 19, 2016 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ezura/bd16fc09e9711ed195672b25788bc59c to your computer and use it in GitHub Desktop.
Save ezura/bd16fc09e9711ed195672b25788bc59c to your computer and use it in GitHub Desktop.
こんな感じで、使うまでに初期化されていることが保証できる + defer = 最後までに絶対に値が決まることが保証できる #swift #CodePiece
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