<div dir="ltr">Hello, folks.<div><br></div><div>I have found a case that lazy initializer is called twice when the initializer is placed in a recursion.</div><div>In this case, I don't have any thought whether it is allowed to be called twice or not. Until now, I have known that lazy keyword guarantees being worked only once. Is it misunderstanding? </div><div><br></div><div>Test code is the following that:</div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">    </span><span class="">lazy</span><span class=""> </span><span class="">var</span><span class=""> testLabel: </span><span class="">UILabel</span><span class=""> = {<br></span><span class="">        </span><span class="">println</span><span class="">(</span><span class="">"testLabel self = </span><span class="">\</span><span class="">(</span><span class="">self</span><span class="">)"</span><span class="">)<br></span><span class="">        </span><span class="">let</span><span class=""> label = </span><span class="">UILabel</span><span class="">()<br></span><span class="">        label.</span><span class="">text</span><span class=""> = </span><span class="">"hello"<br></span><span class="">        </span><span class="">self</span><span class="">.</span><span class="">testLabel</span><span class="">.</span><span class="">text</span><span class=""> = </span><span class="">"world"<br></span><span class="">        </span><span class="">return</span><span class=""> label<br></span><span class="">        }()</span></blockquote>





<p class=""><span class=""><br></span></p><p class=""><span class="">As you know, this code is really nonsense. But, I want to test if lazy guarantees being worked only once or not in the recursion. From this code, I could meet an infinite recursion. </span></p><p class="">Isn't this case included in lazy's guarantee that doing once?</p><p class=""><br></p><p class="">Best regards.</p><p class="">Kyokook Hwang.</p><p class=""><br></p><p class=""><br></p><p class=""><br></p><p class=""><span class=""><br></span></p></div><div><div><div><br></div><div class="gmail_signature"><br></div>
</div></div></div>