Skip to content

Instantly share code, notes, and snippets.

@ukitaka
Created April 25, 2018 09:15
Show Gist options
  • Save ukitaka/a1955a47f28cb33407e2c83a415e4b59 to your computer and use it in GitHub Desktop.
Save ukitaka/a1955a47f28cb33407e2c83a415e4b59 to your computer and use it in GitHub Desktop.
Set value to optional only once.
class MyClass {
var value: Int? {
willSet {
precondition(self.value == nil) }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment