Created
January 25, 2017 10:17
-
-
Save ukitaka/278b901e8f441a1bf37316b3762fe63b to your computer and use it in GitHub Desktop.
Lazy
This file contains hidden or 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 Lazy<A> { | |
| private let a: () -> A | |
| private lazy var lazyA: A = { | |
| return self.a() | |
| }() | |
| var value: A { | |
| return lazyA | |
| } | |
| init(_ a: @escaping @autoclosure () -> A) { | |
| self.a = a | |
| } | |
| init(_ a: @escaping () -> A) { | |
| self.a = a | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment