<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">Thanks. </div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Zhao Xin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 11, 2017 at 2:29 AM, Jordan Rose <span dir="ltr">&lt;<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><div class="h5"><br><div><br><blockquote type="cite"><div>On Jul 7, 2017, at 22:50, Marco S Hyman via swift-users &lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt; wrote:</div><br class="m_-8989070511710417928Apple-interchange-newline"><div><div><br><blockquote type="cite">On Jul 7, 2017, at 9:48 PM, Zhao Xin &lt;<a href="mailto:owenzx@gmail.com" target="_blank">owenzx@gmail.com</a>&gt; wrote:<br><br>Thank you very much Marco. But What is  “outside of an initializer” really bothers me. **Both** `func bar(keysAndValues:Dictionary&lt;<wbr>String, String&gt;)` works now. **Are they really outside ?**<br></blockquote><br>Uhhh, that is certainly not the results I’d have expected.  Perhaps one of the  swift language lawyers can explain.</div></div></blockquote><br></div></div></div><div>The goal is that once the initializer is completed all accesses will go through the setter and therefore trigger willSet/didSet behavior. Since a local function can be assigned to a property or something and get called later, it has to go through the setter as well. So the rules only apply to what&#39;s directly in the body of the initializer, not anything nested. (This includes closures, even.) It might be worth a bug against us at Apple to make this more explicit in the documentation, <a href="https://bugreport.apple.com" target="_blank">https://bugreport.apple.com</a>.</div><div><br></div><div>We also have a bug where &#39;defer&#39; can trigger willSet and didSet behavior as well, <a href="https://bugs.swift.org/browse/SR-1437" target="_blank">SR-1437</a>. But that really is just a bug.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Jordan</div><br></font></span></div></blockquote></div><br></div>