Created
December 31, 2020 00:50
-
-
Save arkilis/86e0a4fb37793405c755c36a24f09e43 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class MyClass { | |
lazy var names: NSArray = { | |
let names = NSArray() | |
print("Only run at the first time access") | |
return names | |
}() | |
} | |
let myClass = MyClass() | |
myClass.names // Only run at the first time access | |
myClass.names // NO OUTPUT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment