I have the same misgivings. The other day, I was wanted to add a piece of metadata to a Slice type conforming to RangeReplaceableCollection (coming from the containing collection) but couldn't figure out a way to make it safe with the empty initializer. It's bugged me a few times similarly.
Cheers! Zachary Waldowski [email protected] On Wed, Jul 6, 2016, at 04:09 AM, Tim Vermeulen via swift-users wrote: > 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. > > 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. > > Perhaps these initialisers should be moved to a (possible new) different > protocol? > _______________________________________________ > swift-users mailing list > [email protected] > https://lists.swift.org/mailman/listinfo/swift-users _______________________________________________ swift-users mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-users
