[swift-users] lazy initialisation

J.E. Schotsman jeschot at xs4all.nl
Mon Jul 4 12:04:42 CDT 2016


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.




More information about the swift-users mailing list