<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=""> </span>@warn_unused_result</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="">func</span> frequencies() -> [<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=""> <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=""> </span>// var dictionary: Dictionary<Self.Generator.Element, Int>() // <<< 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=""> <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=""> 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=""> }</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=""> <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=""> }</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>