<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Feb 19, 2017 at 5:04 PM, 曹剑楠 via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;">Hi All,</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;">I’m coding for section like data structure. </div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;">For example:</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;">I have an Album struct, which has many MediaItems.</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;">It has a sectioned property called &quot;sectionedMediaItemInfos&quot;, which is an array of sections.</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><div><span style="font-variant-ligatures:no-common-ligatures">Each section represents for a disc, and </span>has an &quot;items&quot; array contains all MedaItems in that disc.</div><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div>The define code is like:</div><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div><span style="font-variant-ligatures:no-common-ligatures">```Swift</span></div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><div style="margin:0px;line-height:normal;color:rgb(52,149,175)"><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">public</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">struct</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> Album</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> {</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">public</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">let</span><span style="font-variant-ligatures:no-common-ligatures"> sectionedMediaItemInfos: [</span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">Sectioned</span><span style="font-variant-ligatures:no-common-ligatures">&lt;</span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">MediaItemInfo</span><span style="font-variant-ligatures:no-common-ligatures">&gt;]?</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">}</span></div><div><br></div><div><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">public</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">struct</span><span style="font-variant-ligatures:no-common-ligatures"> Sectioned&lt;Item&gt; : </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">SectionProtocol</span><span style="font-variant-ligatures:no-common-ligatures"> {</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">public</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">let</span><span style="font-variant-ligatures:no-common-ligatures"> title: </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">String</span><span style="font-variant-ligatures:no-common-ligatures">?</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">public</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">let</span><span style="font-variant-ligatures:no-common-ligatures"> items: [</span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">Item</span><span style="font-variant-ligatures:no-common-ligatures">]</span></div><p style="margin:0px;line-height:normal;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures">    </span><br class="m_715390691247048198webkit-block-placeholder"></p><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">public</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">init</span><span style="font-variant-ligatures:no-common-ligatures">(</span><span style="font-variant-ligatures:no-common-ligatures">) {</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">        </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">items</span><span style="font-variant-ligatures:no-common-ligatures"> = </span><span style="font-variant-ligatures:no-common-ligatures">[]</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">        </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">title</span><span style="font-variant-ligatures:no-common-ligatures"> = nil</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    }</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">}</span></div></span></div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">public</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">protocol</span><span style="font-variant-ligatures:no-common-ligatures"> SectionProtocol {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">associatedtype</span><span style="font-variant-ligatures:no-common-ligatures"> SectionItemType</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">var</span><span style="font-variant-ligatures:no-common-ligatures"> items: [SectionItemType] { </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">get</span><span style="font-variant-ligatures:no-common-ligatures"> }</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures">}</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures">```</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures">Now I want to define some extra properties for sections array</span>, like</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;">&quot;sectionMediaItemInfos&quot;.&quot;<wbr>itemsCount&quot; that count all items in each sections.</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;">So I can write that extension:</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;;min-height:13px">```Swift</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">public</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">extension</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">Array</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">where</span><span style="font-variant-ligatures:no-common-ligatures"> Element : SectionProtocol {</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures">    </span><br class="m_715390691247048198webkit-block-placeholder"></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">var</span><span style="font-variant-ligatures:no-common-ligatures"> itemsCount: </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">Int</span><span style="font-variant-ligatures:no-common-ligatures"> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures">        </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">return</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">reduce</span><span style="font-variant-ligatures:no-common-ligatures">(0) { (result, section) </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">in</span><span style="font-variant-ligatures:no-common-ligatures"> result + section.</span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">items</span><span style="font-variant-ligatures:no-common-ligatures">.</span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">count</span><span style="font-variant-ligatures:no-common-ligatures"> }</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures">    }</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures">}</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures">```</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;">So I can get my itemsCount with code like:</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;">```Swift</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;">album.sectionedMediaItemInfos.<wbr>itemsCount</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;">```</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;">That looks good.</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;">Then I want to define code to return all items in this sectioned property.</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures">```Swift</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">public</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">extension</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">Array</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">where</span> <wbr>Element : SectionProtocol {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal;color:rgb(52,149,175)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">var</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> items: [</span><span style="font-variant-ligatures:no-common-ligatures">SectionProtocol</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">.</span><span style="font-variant-ligatures:no-common-ligatures">SectionItemTy<wbr>pe</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">] {</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">        </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">return</span><span style="font-variant-ligatures:no-common-ligatures"> .flatMap { $0.items }</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    }</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">}</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">```</span></div></span></div></div></blockquote><div> </div><div>Sorry, I&#39;m reading this quickly, but I&#39;m confused as to why you&#39;re not writing `var items: [Element.SectionItemType]`. That seems to be what you want, no? `SectionProtocol.SectionItemType` has no constraints and, even if the grammar allowed you to write it, would have to be equivalent to `Any`.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"></span></div><div style="margin:0px;line-height:normal">This doesn’t work. It reported as &quot;Cannot use associated type &#39;SectionItemType&#39; outside of its protocol&quot;</div></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;">The only way to achieve my goals is to untyped the extended &quot;items&quot; property:</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">```Swift</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">public</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">extension</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">Array</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">where</span> <wbr>Element : SectionProtocol {</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal;color:rgb(52,149,175)"><div style="margin:0px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">var</span><span style="font-variant-ligatures:no-common-ligatures"> items: [</span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">Any</span><span style="font-variant-ligatures:no-common-ligatures">] {</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">        </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">return</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">self</span><span style="font-variant-ligatures:no-common-ligatures">.flatMap { $0.items }</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">    }</span></div></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">}</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">```</span></div></span></div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;">Which is not perfect for this case.</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures">So in this special case, I think allow use associated type outside of its protocol is necessary.</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures">And we may allow define protocol with generic type. That would be more convenient.</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">```Swift</span></div><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal;color:rgb(52,149,175)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">public</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">struct</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> Album</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> {</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">public</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">let</span><span style="font-variant-ligatures:no-common-ligatures"> <wbr>sectionedMediaItemInfos: [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">Sectioned</span><span style="font-variant-ligatures:no-common-ligatures">&lt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">MediaItemInfo</span><span style="font-variant-ligatures:no-common-ligatures">&gt;]?</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">}</span></div><div><br></div><div><div style="margin:0px;line-height:normal"><br></div></div><div><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">public</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">struct</span><span style="font-variant-ligatures:no-common-ligatures"> Sectioned&lt;Item&gt; : </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">SectionProtocol</span><span style="font-variant-ligatures:no-common-ligatures"> {</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">public</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">let</span><span style="font-variant-ligatures:no-common-ligatures"> title: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">String</span><span style="font-variant-ligatures:no-common-ligatures">?</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">public</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">let</span><span style="font-variant-ligatures:no-common-ligatures"> items: [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">Item</span><span style="font-variant-ligatures:no-common-ligatures">]</span></div><div style="margin:0px;line-height:normal;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures">    </span><br class="m_715390691247048198webkit-block-placeholder"></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">public</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">init</span><span style="font-variant-ligatures:no-common-ligatures">(</span><span style="font-variant-ligatures:no-common-ligatures">) {</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">        </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">items</span><span style="font-variant-ligatures:no-common-ligatures"> = </span><span style="font-variant-ligatures:no-common-ligatures">[]</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">        </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">title</span><span style="font-variant-ligatures:no-common-ligatures"> = nil</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    }</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">}</span></div></span></div></div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">public</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">protocol</span><span style="font-variant-ligatures:no-common-ligatures"> <wbr>SectionProtocol&lt;<wbr>SectionItemType&gt; {</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">var</span><span style="font-variant-ligatures:no-common-ligatures"> items: [SectionItemType] { </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">get</span><span style="font-variant-ligatures:no-common-ligatures"> }</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">}</span></div></div><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div></div><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">public</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">extension</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">Array</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">where</span> <wbr>Element : SectionProtocol {</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="color:rgb(0,0,0);font-variant-ligatures:no-common-ligatures">    </span><span style="color:rgb(4,51,255);font-variant-ligatures:no-common-ligatures">var</span><span style="font-variant-ligatures:no-common-ligatures"> items: [<font color="#0433ff">Element.</font></span>SectionItemType] {</div><div style="color:rgb(0,0,0);margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">        </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">return</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">self</span><span style="font-variant-ligatures:no-common-ligatures">.flatMap { $0.items }</span></div><div style="color:rgb(0,0,0);margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    }</span></div></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">}</span></div></span></div></div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">```</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">Thank all!</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">Jiannan</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:&#39;Fira Code&#39;"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div></div><br>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br></div></div>