[swift-users] lazy initialisation

Zhao Xin owenzx at gmail.com
Mon Jul 4 12:21:44 CDT 2016


You'd better sharing some of you code here first.

Zhaoxin

On Tue, Jul 5, 2016 at 1:04 AM, J.E. Schotsman via swift-users <
swift-users at swift.org> wrote:

> Hello,
>
> I need to initialize a variable of a class with a closure using the value
> of some variables of the class.
> Since this is not permitted I thought I might solve the problem by
> declaring it lazy. But this is still rejected by the compiler.
> If there are no circular dependencies in initialization of lazy variables
> this could be allowed, couldn’t it?
> Or is this a very big if?
>
> My workaround is ugly: a calculated property + a private variable + an
> initialized:Bool variable.
>
> Jan E.
>
>
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160705/e599429e/attachment.html>


More information about the swift-users mailing list