<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On 6 Jul 2016, at 14:03, Zhao Xin <<a href="mailto:owenzx@gmail.com" class="">owenzx@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_default"><font face="georgia, serif" class="">According to the document of Swift 3, Array has already conformed protocol RangeReplaceableCollection.</font></div></div></div></blockquote><div><br class=""></div>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><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_default"><font face="georgia, serif" class=""><br class=""></font></div><div class="gmail_default"><font face="georgia, serif" class="">Zhaoxin</font></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Jul 6, 2016 at 7:09 PM, Tim Vermeulen via swift-users <span dir="ltr" class=""><<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a>></span> wrote:<br class=""><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 class="">
<br class="">
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 class="">
<br class="">
Perhaps these initialisers should be moved to a (possible new) different protocol?<br class="">
_______________________________________________<br class="">
swift-users mailing list<br class="">
<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class="">
</blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>