<div dir="ltr">Perhaps instead of "auto" we could allow "lazy" to create a default lazy constructor for these cases ?</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 5, 2016 at 12:39 PM, James Campbell <span dir="ltr"><<a href="mailto:james@supmenow.com" target="_blank">james@supmenow.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">See this code:<div>
<p><span>var</span><span> distanceCache: [</span><span>Int</span><span>: </span><span>Int</span><span>] = </span><span>Dictionary</span><span><</span><span>Int</span><span>, </span><span>Int</span><span>>()</span></p><div>It is very long and tedious to write especially if what I am storing changes.</div><div><br></div><div>I propose we be allowed to do the following:</div><div>
<p><i><span>var</span><span> distanceCache: [</span><span>Int</span><span>: </span><span>Int</span><span>] = []</span></i></p><p>If this isn't possible then I wouldn't mind having some way of telling the compiler to auto create it like so:</p><p>
</p><p><i><span>var</span><span> distanceCache: [</span><span>Int</span><span>: </span><span>Int</span><span>] ()</span></i></p><p><span>or</span></p><p>
</p><p><i><span>var</span><span> distanceCache: [</span><span>Int</span><span>: </span><span>Int</span><span>] = new </span><span>Dictionary</span></i></p><p>or even:</p><p><i><span>var</span><span> distanceCache: [</span><span>Int</span><span>: </span><span>Int</span><span>] = auto</span></i></p><p><i><span>auto var</span><span> distanceCache: [</span><span>Int</span><span>: </span><span>Int</span><span>]</span></i><i><span><br></span></i></p><p><span>(auto short for auto create)</span></p><p><span><br></span></p><p>Perhaps this dictionary syntax is just confusing and it was a bad idea to make it the same as an array. Most languages use "{" so why did swift choose to share "[" with arrays and dictionaries.<span class="HOEnZb"><font color="#888888"><br></font></span></p></div><span class="HOEnZb"><font color="#888888">-- <br><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><span style="font-size:16px;line-height:19.2px"></span><span style="font-size:12.8px"> Wizard</span><br></div><div><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a></div><div><a href="tel:%2B44%207523%20279%20698" value="+447523279698" target="_blank">+44 7523 279 698</a></div></div></div></div></div></div>
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><span style="font-size:16px;line-height:19.2px"></span><span style="font-size:12.8px"> Wizard</span><br></div><div><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a></div><div>+44 7523 279 698</div></div></div></div></div></div>
</div>