<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="">In Swift, we cannot compile:<div class=""><font face="Menlo" size="2" class=""><br class=""></font></div><div class=""><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">_</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> = [[], </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">1</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">2</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">3</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], [[</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">4</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">5</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">6</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">7</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">8</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">9</span><span class="" style="font-variant-ligatures: no-common-ligatures;">]]]</span></font></div></div></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" size="2" class=""><br class=""></font></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">The reason for the compile-time error is that we are not in fact creating an array, but a tree – a more general structure of which arrays are only a special case. Given the well-deserved and growing reputation of Swift, one would hope that in this instance the compiler would be able to default to something like a:</span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" size="2" class=""><br class=""></font></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" size="2" class=""><div class="" style="margin: 0px; line-height: normal;"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">enum</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> Tree<Value> {</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">case</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> Leaf(</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Value</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">case</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> Branches([</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Tree</span><span class="" style="font-variant-ligatures: no-common-ligatures;">])</span></font></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><font class="">}</font></span></div><div class="" style="margin: 0px; line-height: normal; min-height: 17px;"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></font></div><div class="" style="margin: 0px; line-height: normal; color: rgb(73, 162, 210);"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">extension</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span><span class="" style="font-variant-ligatures: no-common-ligatures;">Tree</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> : </span><span class="" style="font-variant-ligatures: no-common-ligatures;">ArrayLiteralConvertible</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> {</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">init</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(arrayLiteral elements: </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Tree</span><span class="" style="font-variant-ligatures: no-common-ligatures;">...) {</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">                </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">self</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> = .</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Branches</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(elements)</span></font></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><font class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>}</font></span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><font class="">}</font></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div></font></div></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">For this to work in the playground, however, we must manually lift the values into the world of trees first. And to make that chore in turn easier on the eye we can introduce a:</span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" size="2" class=""><br class=""></font></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" size="2" class=""><div class="" style="margin: 0px; line-height: normal; color: rgb(203, 203, 203);"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">prefix</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">operator</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> ◊ {} </span><span class="" style="font-variant-ligatures: no-common-ligatures;">// looks a bit like a leaf (us/uk kbd: </span><span class="" style="line-height: normal; font-variant-ligatures: no-common-ligatures;"><b class="">⎇⇧</b></span><span class="" style="font-variant-ligatures: no-common-ligatures;">V)</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">prefix</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">func</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> ◊ <T> (leaf: </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">T</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) -> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Tree</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">T</span><span class="" style="font-variant-ligatures: no-common-ligatures;">> { </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">return</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> .</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Leaf</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(leaf) }</span></font></div><div class="" style="margin: 0px; line-height: normal; min-height: 17px;"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> tree: </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Tree</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Int</span><span class="" style="font-variant-ligatures: no-common-ligatures;">> = [[], </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">1</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">2</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">3</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], [[</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">4</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">5</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">6</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">7</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">8</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">9</span><span class="" style="font-variant-ligatures: no-common-ligatures;">]]]</span></font></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div></font></span></div><div class="">The point here is that if adding such a fundamental type to the Standard Library would not be a priority at present, it is not the end of the world since we can easily enough write it ourselves… What we cannot do ourselves, however, is to get rid of the need for that operator in the common scenario of initialising with literal values. For this we need a literal-convertible protocol requiring <b class="">two</b> initialisers:</div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" size="2" class=""><br class=""></font></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><div style="margin: 0px; line-height: normal;" class=""><font face="Menlo" size="2" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);" class="">protocol</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="color: rgb(73, 162, 210);" class="">TreeLiteralConvertible</span> {</div><div style="margin: 0px; line-height: normal; color: rgb(200, 172, 229);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures" class="">associatedtype</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> LeafValue</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures; color: #c8ace5" class="">init</span><span style="font-variant-ligatures: no-common-ligatures" class="">(literal: </span><span style="font-variant-ligatures: no-common-ligatures; color: #49a2d2" class="">Self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.LeafValue...)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures; color: #c8ace5" class="">init</span><span style="font-variant-ligatures: no-common-ligatures" class="">(literal: </span><span style="font-variant-ligatures: no-common-ligatures; color: #49a2d2" class="">Self</span><span style="font-variant-ligatures: no-common-ligatures" class="">...)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></font></div></div></div></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">Then we could simply:</span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" size="2" class=""><br class=""></font></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> tree: </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Tree</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Int</span><span class="" style="font-variant-ligatures: no-common-ligatures;">> = [[], </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">1</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">2</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">3</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], [[</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">4</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">5</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">6</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">7</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">8</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">9</span><span class="" style="font-variant-ligatures: no-common-ligatures;">]]]</span></font></div></div></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" size="2" class=""><br class=""></font></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">And, whilst we are at it, we could also get rid of the need for that operator in the case of nested associative arrays (again, you can try this in the playground):</span></div><div class=""><font face="Menlo" size="2" class=""><br class=""></font></div><div class=""><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">enum</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> <span style="color: rgb(73, 162, 210);" class="">DictionaryTree</span><Key, Value> {</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">case</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> Leaf(</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Value</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">case</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> Branches([(</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Key</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">DictionaryTree</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)])</span></font></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" class="" size="2">}</font></span></div><div class="" style="margin: 0px; line-height: normal; min-height: 17px;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></font></div><div class="" style="margin: 0px; line-height: normal; color: rgb(73, 162, 210);"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">extension</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span><span class="" style="font-variant-ligatures: no-common-ligatures;">DictionaryTree</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> : </span><span class="" style="font-variant-ligatures: no-common-ligatures;">DictionaryLiteralConvertible</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> {</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">init</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(dictionaryLiteral pairs: (</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Key</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">DictionaryTree</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)...) {</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">                </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">self</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> = .</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Branches</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(pairs)</span></font></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" class="" size="2"><span class="Apple-tab-span" style="white-space: pre;">        </span>}</font></span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" class="" size="2">}</font></span></div><div class="" style="margin: 0px; line-height: normal; min-height: 17px;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">prefix</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">func</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> ◊ <Key, Value> (leaf: </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Value</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) -> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">DictionaryTree</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Key</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Value</span><span class="" style="font-variant-ligatures: no-common-ligatures;">> { </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">return</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> .</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Leaf</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(leaf) }</span></font></div></div><div class=""><div class="" style="margin: 0px; line-height: normal; min-height: 17px;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></font></div><div class="" style="margin: 0px; line-height: normal; color: rgb(73, 162, 210);"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> map: </span><span class="" style="font-variant-ligatures: no-common-ligatures;">DictionaryTree</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"><</span><span class="" style="font-variant-ligatures: no-common-ligatures;">String</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">,</span><span class="" style="font-variant-ligatures: no-common-ligatures;">Int</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">> = [</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(100, 150, 29);">"A"</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> : [:],</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(100, 150, 29);">"B"</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> : [</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">                </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(100, 150, 29);">"Ba"</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> : </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">0</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">                </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(100, 150, 29);">"Bb"</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> : </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">0</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">                </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(100, 150, 29);">"Bc"</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> : [</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">                        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(100, 150, 29);">"Bc1"</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> : </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">0</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">                        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(100, 150, 29);">"Bc2"</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> : </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">0</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">                        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(100, 150, 29);">"Bc3"</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> : </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">0</span></font></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" class="" size="2"><span class="Apple-tab-span" style="white-space: pre;">                </span>]</font></span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" class="" size="2"><span class="Apple-tab-span" style="white-space: pre;">        </span>]</font></span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" class="" size="2">]</font></span></div></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" size="2" class=""><br class=""></font></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">… by introducing an analogous protocol:</span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" size="2" class=""><br class=""></font></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" size="2" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);" class="">protocol</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> <span style="color: rgb(73, 162, 210);" class="">DictionaryTreeLiteralConvertible</span> {</span></div><div style="margin: 0px; line-height: normal; color: rgb(200, 172, 229);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures" class="">associatedtype</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> Key</span></div><div style="margin: 0px; line-height: normal; color: rgb(200, 172, 229);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures" class="">associatedtype</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> LeafValue</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures; color: #c8ace5" class="">init</span><span style="font-variant-ligatures: no-common-ligatures" class="">(literal: </span><span style="font-variant-ligatures: no-common-ligatures; color: #49a2d2" class="">Self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.LeafValue...)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures; color: #c8ace5" class="">init</span><span style="font-variant-ligatures: no-common-ligatures" class="">(literal: (Key, </span><span style="font-variant-ligatures: no-common-ligatures; color: #49a2d2" class="">Self</span><span style="font-variant-ligatures: no-common-ligatures" class="">)...)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></font></div></span></div><div class="">Please note: I do understand that fleshing out these structures (along with all the juicy methods, operators and lazy alternatives) may not currently be a priority for Swift. The two literal-convertible protocols however, may be a much less daunting task, which would open to us some very useful programming idioms…</div><div class=""><br class=""></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">milos</span></div></body></html>