<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Yes. All of these variants are covered in the book The Swift Programming Language in some detail.<div class=""><br class=""></div><div class="">Alex<br class=""><div class=""><br class=""><div class="">
–––––<br class="">Alexander Kempgen<br class=""><a href="mailto:alex@kempgen.de" class="">alex@kempgen.de</a>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">Am 05.01.2016 um 14:42 schrieb James Campbell via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>>:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">So the [Int]() is shorthand for Array<Int>()</div><div class="gmail_extra" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""><div class="gmail_quote">On Tue, Jan 5, 2016 at 1:01 PM, Jeremy Pereira<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:jeremy.j.pereira@googlemail.com" target="_blank" class="">jeremy.j.pereira@googlemail.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><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=""><br class="">> On 5 Jan 2016, at 12:51, James Campbell <<a href="mailto:james@supmenow.com" class="">james@supmenow.com</a>> wrote:<br class="">><br class="">> The problem for me is that is so counter intuitive I didn't even know you could do that.<br class=""><br class=""></span>The first one is a bit counter intuitive and I agree that<br class=""><br class="">var distanceCache: [Int: Int] = []<br class=""><br class="">might be an improvement, albeit not one I think many people would agree is worth doing. However, the second one is a natural extrapolation from the equivalent array syntax i.e.<br class=""><br class="">var array = [Int]()<br class="">var dictionary = [String: Int]()<br class=""><div class="HOEnZb"><div class="h5"><br class="">><br class="">> On Tue, Jan 5, 2016 at 12:50 PM, Jeremy Pereira <<a href="mailto:jeremy.j.pereira@googlemail.com" class="">jeremy.j.pereira@googlemail.com</a>> wrote:<br class="">> I don’t understand what the problem is<br class="">><br class="">> > On 5 Jan 2016, at 12:39, James Campbell via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class="">> ><br class="">> > See this code:<br class="">> > var distanceCache: [Int: Int] = Dictionary<Int, Int>()<br class="">> ><br class="">> > It is very long and tedious to write especially if what I am storing changes.<br class="">> ><br class="">> > I propose we be allowed to do the following:<br class="">> > var distanceCache: [Int: Int] = []<br class="">><br class="">> You can do<br class="">><br class="">> var distanceCache: [Int: Int] = [:]<br class="">><br class="">> Also<br class="">><br class="">> var distanceCache2 = [Int: Int]()<br class="">><br class="">><br class="">> > 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.<br class="">><br class="">> It’s not the same, you need the colons inside. I imagine that braces were discarded on the grounds that it would confuse the compiler with respect to closures, for example<br class="">><br class="">> var myClosure = {} // is a variable of type () -> ()<br class="">><br class="">><br class="">> ><br class="">> > --<br class="">> > Wizard<br class="">> ><span class="Apple-converted-space"> </span><a href="mailto:james@supmenow.com" class="">james@supmenow.com</a><br class="">> ><span class="Apple-converted-space"> </span><a href="tel:%2B44%207523%20279%20698" value="+447523279698" class="">+44 7523 279 698</a><br class="">> > _______________________________________________<br class="">> > swift-evolution mailing list<br class="">> ><span class="Apple-converted-space"> </span><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">> ><span class="Apple-converted-space"> </span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">><br class="">><br class="">><br class="">><br class="">> --<br class="">> Wizard<br class="">><span class="Apple-converted-space"> </span><a href="mailto:james@supmenow.com" class="">james@supmenow.com</a><br class="">><span class="Apple-converted-space"> </span><a href="tel:%2B44%207523%20279%20698" value="+447523279698" class="">+44 7523 279 698</a><br class=""><br class=""></div></div></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>--<span class="Apple-converted-space"> </span><br class=""><div class="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><span style="font-size: 16px; line-height: 19.2px;" class=""></span><span style="font-size: 12.8px;" class=""> Wizard</span><br class=""></div><div class=""><a href="mailto:james@supmenow.com" target="_blank" class="">james@supmenow.com</a></div><div class="">+44 7523 279 698</div></div></div></div></div></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=yq8Z-2B6DbjIeYJxjP5VY6WZ0xKXr0MrPUrp8QvDyF-2BJYXJbOqkzUecjdGJkfpwZTPFytxzIBZatpJwa1FgyG8Q6WTXt2fw9mYuOFvcrthQGcQtav2vFK93i5UzM-2B9X-2BZtu93sxCf723LyETeCb6VajXE7DMNEoJmUs6NYrybXweLhYhz2H2O3IUcEKgiP023DtJfxvqDgJStQgSUDdtV-2B1IXENvfgedZhm4jNIM0cPKM-3D" alt="" width="1" height="1" border="0" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space"> </span>_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></div></div></body></html>