Skip to content

Instantly share code, notes, and snippets.

@qwzybug
Created July 9, 2014 21:22
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 qwzybug/177c2acbf6e29352e563 to your computer and use it in GitHub Desktop.
Save qwzybug/177c2acbf6e29352e563 to your computer and use it in GitHub Desktop.
Lazy computed properties in Swift
import Cocoa
class TestClass {
@lazy var lazy: NSDate = {
return NSDate.date()
}()
}
let t = TestClass()
println(t.lazy)
sleep(1)
println(t.lazy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment