Created
August 19, 2014 13:12
-
-
Save zwaldowski/18d4849f71ea8a665151 to your computer and use it in GitHub Desktop.
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
class MyClass { | |
lazy var property: String! = { | |
println("Inside the initializer!") | |
return "Fallback" | |
}() | |
} | |
let obj = MyClass() | |
println("property: \(obj.property)") | |
obj.property = "Foo" | |
println("property: \(obj.property)") | |
obj.property = nil | |
println("property: \(obj.property)") | |
/** | |
Console output: | |
Inside the initializer! | |
property: Fallback | |
property: Foo | |
Inside the initializer! | |
property: Fallback | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@a2: I reformatted it in GitHub.