Skip to content

Instantly share code, notes, and snippets.

@arkilis
Created December 31, 2020 00:50
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 arkilis/86e0a4fb37793405c755c36a24f09e43 to your computer and use it in GitHub Desktop.
Save arkilis/86e0a4fb37793405c755c36a24f09e43 to your computer and use it in GitHub Desktop.
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