Skip to content

Instantly share code, notes, and snippets.

@arkilis
Created Dec 31, 2020
Embed
What would you like to do?
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