[swift-evolution] Default lazy constructor
James Campbell
james at supmenow.com
Tue Jan 5 07:48:03 CST 2016
When creating a lazy variable, maybe we should allow for default closures,
i.e
lazy var userSession: UserSession
Which will construct that object for you
instead of having to do:
lazy var object: MyObject {
let userSession = UserSession()
return userSession
}()
If the initializer requires parameter values then as an extension of this
we could pass them in psuedo C++ style:
lazy var object: UserSession(otherVariable)
Potentially otherVariable in this case could be lazily processed, so that
its the equivalent of:
lazy var object: MyObject {
let userSession = UserSession(otherVariable)
return userSession
}()
--
Wizard
james at supmenow.com
+44 7523 279 698
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160105/b79e3609/attachment.html>
More information about the swift-evolution
mailing list