Created
September 23, 2020 07:35
-
-
Save swiftyfinch/9c3d8e11f0f59802dd9476b0a81615f2 to your computer and use it in GitHub Desktop.
LazyOnce example (for post: https://medium.com/@tinkoffhere/b22f51422345).
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
final class Storage { | |
init() { print(“Storage init.”) } | |
} | |
final class Example { | |
@LazyOnce var storage = Storage() | |
} | |
let example = Example() // Output: | |
example.storage // Output: Storage init. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment