<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=""><div class="">Hi everyone,</div><div class=""><br class=""></div><div class="">Does anyone know why Swift won’t let me use the alternative way below to init the dictionary?</div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #de348c" class="">public</span> <span style="font-variant-ligatures: no-common-ligatures; color: #de348c" class="">extension</span> <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">SequenceType</span> <span style="font-variant-ligatures: no-common-ligatures; color: #de348c" class="">where</span> <span style="font-variant-ligatures: no-common-ligatures; color: #de348c" class="">Self</span>.Generator.Element: Hashable {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(222, 52, 140);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span>@warn_unused_result</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #de348c" class="">func</span> frequencies() -&gt; [<span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">Self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">Generator</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">Element</span>: <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">Int</span>] {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #de348c" class="">var</span> dictionary: [<span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">Self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">Generator</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">Element</span>: <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">Int</span>] = [:]</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal; color: rgb(192, 192, 192);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span>// var dictionary: Dictionary&lt;Self.Generator.Element, Int&gt;() // &lt;&lt;&lt; Not allowed!</div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #de348c" class="">for</span> element <span style="font-variant-ligatures: no-common-ligatures; color: #de348c" class="">in</span> <span style="font-variant-ligatures: no-common-ligatures; color: #de348c" class="">self</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dictionary[element] = dictionary[element]?.<span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">successor</span>() ?? 1</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #de348c" class="">return</span> dictionary</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">I’m using Swift 2.1 and Xcode 7.2.</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">Best,</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">— A</div></body></html>