Skip to content

Instantly share code, notes, and snippets.

@nsoojin
Last active October 26, 2019 09:46
Show Gist options
  • Save nsoojin/1c77774279e1954de5ddec1d71ad84c1 to your computer and use it in GitHub Desktop.
Save nsoojin/1c77774279e1954de5ddec1d71ad84c1 to your computer and use it in GitHub Desktop.
LateInitialized Property Wrapper
@propertyWrapper
struct LateInitialized<T> {
var storage: T? = nil
var wrappedValue: T {
get {
guard let value = storage else {
fatalError("value has not been set!")
}
return value
}
set {
storage = newValue
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment