Created
November 22, 2018 00:44
-
-
Save lilyball/6078349909c11501d1e5318f4b27c813 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
struct Foo { | |
var fakeLazy: Int { | |
mutating get { | |
if let value = _fakeLazy { return value } | |
let value = calculateLazyValue() | |
_fakeLazy = value | |
return value | |
} | |
set { | |
_fakeLazy = newValue | |
} | |
} | |
private var _fakeLazy: Int? | |
private func calculateLazyValue() -> Int { | |
return 42 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment