<div dir="ltr">Thanks to matt on stack overflow, you need to assign it to a temporary to ensure the type is correct: <div><br></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="color:rgb(187,44,162)">let</span><span style="font-variant-ligatures: no-common-ligatures;"> w : </span><span style="color:rgb(79,129,135)">H</span><span style="font-variant-ligatures: no-common-ligatures;"> = </span><span style="color:rgb(79,129,135)">K</span><span style="font-variant-ligatures: no-common-ligatures;">(v:</span><span style="color:rgb(39,42,216)">3</span><span style="font-variant-ligatures: no-common-ligatures;">)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="color:rgb(187,44,162)">let</span><span style="font-variant-ligatures: no-common-ligatures;"> x : </span><span style="color:rgb(79,129,135)">H</span><span style="font-variant-ligatures: no-common-ligatures;"> = </span><span style="color:rgb(79,129,135)">J</span><span style="font-variant-ligatures: no-common-ligatures;">(v:</span><span style="color:rgb(39,42,216)">3</span><span style="font-variant-ligatures: no-common-ligatures;">)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="color:rgb(79,129,135)">af</span><span style="font-variant-ligatures: no-common-ligatures;"> += [</span><span style="color:rgb(79,129,135)">w</span><span style="font-variant-ligatures: no-common-ligatures;">]</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="color:rgb(79,129,135)">af</span><span style="font-variant-ligatures: no-common-ligatures;"> += [</span><span style="color:rgb(79,129,135)">x</span><span style="font-variant-ligatures: no-common-ligatures;">]</span></p></div><div><br></div><div>Is this worthy of a bug report? Or is it inherent in the design of the language? </div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 25, 2016 at 1:02 PM, Paul Ossenbruggen <span dir="ltr"><<a href="mailto:possen@gmail.com" target="_blank">possen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">In swift 3.0 beta 3, I defined a fairly simple protocol and two structs that implement it, if I initialize the array when creating the objects, it works, but if I try to add elements I get an error:<div><br></div><div>Cannot convert value of type '[H]' to expected argument type 'inout _'<br><div><br></div><div>Shouldn't this work?</div><div><br></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(187,44,162)"><span>protocol</span><span style="color:rgb(0,0,0)"> H {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span> </span><span style="color:rgb(187,44,162)">var</span><span> v : </span><span style="color:rgb(112,61,170)">Int</span><span> { </span><span style="color:rgb(187,44,162)">get</span><span> </span><span style="color:rgb(187,44,162)">set</span><span> }</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span> </span><span style="color:rgb(187,44,162)">func</span><span> hello()</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span>}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px"><span></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="color:rgb(187,44,162)">struct</span><span> J : </span><span style="color:rgb(79,129,135)">H</span><span> {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span> </span><span style="color:rgb(187,44,162)">var</span><span> v : </span><span style="color:rgb(112,61,170)">Int</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span> </span><span style="color:rgb(187,44,162)">func</span><span> hello() {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span> </span><span style="color:rgb(61,29,129)">print</span><span>(</span><span style="color:rgb(209,47,27)">"j"</span><span>)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span> }</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span>}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px"><span></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="color:rgb(187,44,162)">struct</span><span> K : </span><span style="color:rgb(79,129,135)">H</span><span> {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span> </span><span style="color:rgb(187,44,162)">var</span><span> v : </span><span style="color:rgb(112,61,170)">Int</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span> </span><span style="color:rgb(187,44,162)">func</span><span> hello() {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span> </span><span style="color:rgb(61,29,129)">print</span><span>(</span><span style="color:rgb(209,47,27)">"k"</span><span>)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span> }</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span>}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px"><span></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="color:rgb(187,44,162)">let</span><span> ag:[</span><span style="color:rgb(79,129,135)">H</span><span>] = [</span><span style="color:rgb(79,129,135)">K</span><span>(v:</span><span style="color:rgb(39,42,216)">3</span><span>), </span><span style="color:rgb(79,129,135)">J</span><span>(v:</span><span style="color:rgb(39,42,216)">4</span><span>)]</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="color:rgb(79,129,135)">ag</span><span>[</span><span style="color:rgb(39,42,216)">0</span><span>].</span><span style="color:rgb(49,89,93)">hello</span><span>()</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="color:rgb(79,129,135)">ag</span><span>[</span><span style="color:rgb(39,42,216)">1</span><span>].</span><span style="color:rgb(49,89,93)">hello</span><span>() //works</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px"><span></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="color:rgb(187,44,162)">var</span><span> af:[</span><span style="color:rgb(79,129,135)">H</span><span>] = []</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="color:rgb(79,129,135)">af</span><span> += [</span><span style="color:rgb(79,129,135)">K</span><span>(v:</span><span style="color:rgb(39,42,216)">3</span><span>)] // does not work</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="color:rgb(79,129,135)">af</span><span> += [</span><span style="color:rgb(79,129,135)">J</span><span>(v:</span><span style="color:rgb(39,42,216)">4</span><span>)]</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="color:rgb(79,129,135)">af</span><span>[</span><span style="color:rgb(39,42,216)">0</span><span>].</span><span style="color:rgb(49,89,93)">hello</span><span>()</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="color:rgb(79,129,135)">af</span><span>[</span><span style="color:rgb(39,42,216)">1</span><span>].</span><span style="color:rgb(49,89,93)">hello</span><span>() </span></p></div><div><span><br></span></div></div></div>
</blockquote></div><br></div></div>