<div dir="ltr"><div class="gmail_default"><font face="georgia, serif">Then how you defined the index to conform to Strideable? Below code does work as it seams that you can't use generics in subscripts.</font></div><div class="gmail_default"><font face="georgia, serif"><br></font></div><div class="gmail_default"><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">subscript</span><span style=""><T:Strideable>(index:T) -> Element</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><br></span></p><p style="margin:0px;line-height:normal"><font color="#000000" face="georgia, serif">Zhaoxin</font></p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 6, 2016 at 8:32 PM, Tim Vermeulen <span dir="ltr"><<a href="mailto:tvermeulen@me.com" target="_blank">tvermeulen@me.com</a>></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"><br><div><span class=""><blockquote type="cite"><div>On 6 Jul 2016, at 14:03, Zhao Xin <<a href="mailto:owenzx@gmail.com" target="_blank">owenzx@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div class="gmail_default"><font face="georgia, serif">According to the document of Swift 3, Array has already conformed protocol RangeReplaceableCollection.</font></div></div></div></blockquote><div><br></div></span>That’s exactly why I also want to conform my wrapper to that protocol? I think there’s a misunderstanding. I’m making a collection that can be subscripted with any index (that conforms to Strideable), but behaves like an array otherwise.</div><span class=""><div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_default"><font face="georgia, serif"><br></font></div><div class="gmail_default"><font face="georgia, serif">Zhaoxin</font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 6, 2016 at 7:09 PM, Tim Vermeulen via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">RangeReplaceableCollection has three initialisers: init(), init(_:) and init(repeating:count:). The latter two are implemented using the empty initialiser. But why are these initialisers part of this particular protocol? As far as I can tell, no other methods of this protocol depend on these initialisers. The requirement of the empty initialiser makes it impossible to have a collection conform to this protocol that needs additional data for its initialisation.<br>
<br>
For instance, I was making an array that works with any Strideable indices, not just integers. A startIndex is needed for its initialisation, so I can’t really conform it to RangeReplaceableCollection. If I do it anyways (with a fatalError() in the required empty initialiser) everything seems to work just fine, except for the protocol’s three initialisers.<br>
<br>
Perhaps these initialisers should be moved to a (possible new) different protocol?<br>
_______________________________________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
</blockquote></div><br></div>
</div></blockquote></div><br></span></div></blockquote></div><br></div>