<div dir="ltr"><div class="gmail_default"><p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(186,45,162)">import<span style="color:rgb(0,0,0)"> Cocoa</span></p>
<p style="font-family:Helvetica;margin:0px;font-size:12px;line-height:normal;min-height:14px"><br></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(186,45,162)">struct<span style="color:rgb(0,0,0)"> Foo {</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)">    <span style="color:rgb(186,45,162)">var</span> keys = [<span style="color:rgb(209,47,27)">&quot;z&quot;</span>,<span style="color:rgb(209,47,27)">&quot;y&quot;</span>,<span style="color:rgb(209,47,27)">&quot;x&quot;</span>]</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)">    {</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)">        <span style="color:rgb(186,45,162)">didSet</span> {</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)">            <span style="color:rgb(79,129,135)">keys</span>.<span style="color:rgb(62,30,129)">sort</span>()</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)">        }</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)">    }</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0);min-height:13px">    </p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)">    <span style="color:rgb(186,45,162)">init</span>(keysAndValues:<span style="color:rgb(112,61,170)">Dictionary</span>&lt;<span style="color:rgb(112,61,170)">String</span>, <span style="color:rgb(112,61,170)">String</span>&gt;) {</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)">        <span style="color:rgb(186,45,162)">self</span>.<span style="color:rgb(79,129,135)">keys</span>.<span style="color:rgb(62,30,129)">append</span>(contentsOf: keysAndValues.<span style="color:rgb(112,61,170)">keys</span>)</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)">    }</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)">}</p>
<p style="font-family:Helvetica;margin:0px;font-size:12px;line-height:normal;min-height:14px"><br></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)"><span style="color:rgb(186,45,162)">let</span> keysAndValues:<span style="color:rgb(112,61,170)">Dictionary</span>&lt;<span style="color:rgb(112,61,170)">String</span>,<span style="color:rgb(112,61,170)">String</span>&gt; = [<span style="color:rgb(209,47,27)">&quot;c&quot;</span>:<span style="color:rgb(209,47,27)">&quot;c&quot;</span>, <span style="color:rgb(209,47,27)">&quot;b&quot;</span>:<span style="color:rgb(209,47,27)">&quot;b&quot;</span>, <span style="color:rgb(209,47,27)">&quot;a&quot;</span>:<span style="color:rgb(209,47,27)">&quot;a&quot;</span>]</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"><span style="color:rgb(186,45,162)">var</span><span style="color:rgb(0,0,0)"> foo = </span><span style="color:rgb(79,129,135)">Foo</span><span style="color:rgb(0,0,0)">(keysAndValues: </span><span style="color:rgb(79,129,135)">keysAndValues</span><span style="color:rgb(0,0,0)">) </span>// `let foo` is the same result</p>
<p style="font-family:Helvetica;margin:0px;font-size:12px;line-height:normal;min-height:14px"><br></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(62,30,129)"><span style="color:rgb(79,129,135)">foo</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(79,129,135)">keys</span><span style="color:rgb(0,0,0)">.</span>forEach<span style="color:rgb(0,0,0)"> { </span>print<span style="color:rgb(0,0,0)">($0) }</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,132,0)">/*</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,132,0)"> prints</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,132,0)"> z</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,132,0)"> y</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,132,0)"> x</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,132,0)"> b</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,132,0)"> c</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,132,0)"> a</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,132,0)">*/</p><p style="margin:0px;line-height:normal"><font face="georgia, serif" color="#000000"><br></font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif" color="#000000">Above code doesn&#39;t call `didSet` in playground. My .swift file is similar and didn&#39;t call `didSet` either. However, if without a struct, `didSet` is called.</font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif" color="#000000"><br></font></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="color:rgb(186,45,162)">var</span> keys = [<span style="color:rgb(209,47,27)">&quot;z&quot;</span>,<span style="color:rgb(209,47,27)">&quot;y&quot;</span>,<span style="color:rgb(209,47,27)">&quot;x&quot;</span>]</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">{</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(186,45,162)"><span style="color:rgb(0,0,0)">    </span>didSet<span style="color:rgb(0,0,0)"> {</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">        <span style="color:rgb(79,129,135)">keys</span>.<span style="color:rgb(62,30,129)">sort</span>()</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">    }</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">}</p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica;min-height:14px"><br></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="color:rgb(186,45,162)">let</span> keysAndValues:<span style="color:rgb(112,61,170)">Dictionary</span>&lt;<span style="color:rgb(112,61,170)">String</span>,<span style="color:rgb(112,61,170)">String</span>&gt; = [<span style="color:rgb(209,47,27)">&quot;c&quot;</span>:<span style="color:rgb(209,47,27)">&quot;c&quot;</span>, <span style="color:rgb(209,47,27)">&quot;b&quot;</span>:<span style="color:rgb(209,47,27)">&quot;b&quot;</span>, <span style="color:rgb(209,47,27)">&quot;a&quot;</span>:<span style="color:rgb(209,47,27)">&quot;a&quot;</span>]</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)">keys<span style="color:rgb(0,0,0)">.</span><span style="color:rgb(62,30,129)">append</span><span style="color:rgb(0,0,0)">(contentsOf: </span>keysAndValues<span style="color:rgb(0,0,0)">.</span><span style="color:rgb(112,61,170)">keys</span><span style="color:rgb(0,0,0)">)</span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica;min-height:14px"><br></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica;min-height:14px"><br></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(62,30,129)"><span style="color:rgb(79,129,135)">keys</span><span style="color:rgb(0,0,0)">.</span>forEach<span style="color:rgb(0,0,0)"> { </span>print<span style="color:rgb(0,0,0)">($0) }</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)">/*</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"> prints</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"> a</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"> b</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"> c</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"> x</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"> y</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"> z</p><p style="margin:0px;line-height:normal">



















</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"> */</p><p style="margin:0px;line-height:normal"><br></p><p style="margin:0px;line-height:normal"><font face="georgia, serif" color="#000000"><br></font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif"><i><font color="#000000">Xcode </font>9.0 beta 2 (9M137d)</i></font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif"><i><br></i></font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif"><i>Apple Swift version 4.0 (swiftlang-900.0.45.6 clang-900.0.26)</i></font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif"><i>Target: x86_64-apple-macosx10.9</i></font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif"><i><br></i></font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif"><i>macOS Sierra 10.12.5 (16F73)</i></font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif"><br></font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif"><br></font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif">Zhao Xin</font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif" color="#000000"><br></font></p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 7, 2017 at 11:52 PM, 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"><div>It definitely should. Can you show the code where it wasn’t being called?</div><div><br></div><div>Thanks!</div><div>Jordan</div><div><br></div><br><div><blockquote type="cite"><div><div class="h5"><div>On Jul 7, 2017, at 00:31, Zhao Xin via swift-users &lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt; wrote:</div><br class="m_-8295508605038253110Apple-interchange-newline"></div></div><div><div><div class="h5"><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">Should Array&#39;s `append(_)` functions cause the array&#39;s `didSet`?</div><div class="gmail_default" style="font-family:georgia,serif">In my own test, it did call `didSet` in Playground. But in .swift files, it didn&#39;t call.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Is this a known bug or something? Which is correct?</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Xcode Version 9.0 beta 2 (9M137d)​<br></div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default"><div style="margin:0px;line-height:normal"><font face="georgia, serif">swift --version</font></div><div style="margin:0px;line-height:normal"><font face="georgia, serif">Apple Swift version 4.0 (swiftlang-900.0.45.6 clang-900.0.26)</font></div><div style="margin:0px;line-height:normal"><font face="georgia, serif">Target: x86_64-apple-macosx10.9</font></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><font face="georgia, serif"><br></font></span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><font face="georgia, serif"><br></font></span></div><div style="margin:0px;line-height:normal"><font face="georgia, serif">Zhao Xin</font></div></div></div></div></div>
______________________________<wbr>_________________<br>swift-users mailing list<br><a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-users" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br></div></blockquote></div><br></div></blockquote></div><br></div>