<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">Meant to respond to the list with this reply:<div><br></div><div><span style="background-color: rgba(255, 255, 255, 0);">The Index associated type used to show up on <a href="http://developer.apple.com/">developer.apple.com</a>. The way it’s declared changed between Swift 3.x and Swift 4.0 such that it doesn’t appear anymore. (It’s declared as part of _IndexableBase, where the underscore indicates that the type is intended to be an undocumented implementation detail: <a href="https://github.com/apple/swift/blob/master/docs/StdlibRationales.rst#protocols-with-restricted-conformance-rules">https://github.com/apple/swift/blob/master/docs/StdlibRationales.rst#protocols-with-restricted-conformance-rules</a>)</span><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">On the current swift-4.1-branch, Index is declared directly on Collection, so it should start showing up again in the future.<br><br></span><div><span style="background-color: rgba(255, 255, 255, 0);">-Kyle</span></div></div><div><br>On Dec 15, 2017, at 10:06 PM, Howard Lovatt via swift-users <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="content-type" content="text/html; charset=utf-8">It’s a problem with Apple documentation. <a href="http://swiftdoc.org">swiftdoc.org</a> does list the associated types, but is no longer maintained :(. <br><br><div id="AppleMailSignature">-- Howard.</div><div><br>On 16 Dec 2017, at 1:17 pm, Nevin Brackett-Rozinsky via swift-users <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">In Xcode if I write,<div><br></div><div><div><font face="monospace, monospace">extension Collection {</font></div><div><font face="monospace, monospace"> var secondIndex: Index { return index(after: startIndex) }</font></div><div><font face="monospace, monospace">}</font></div></div><div><br></div><div>and then option-click on “Index”, it shows “associatedtype Index : Comparable” followed by a description. Is this documented somewhere?</div><div><br></div><div>When I look at the <a href="https://developer.apple.com/documentation/swift/collection" target="_blank">documentation for Collection</a> on <a href="http://developer.apple.com">developer.apple.com</a> there is no mention of an Index associated type. I also don’t see it in The Swift Programming Language.</div><div><br></div><div>If someone didn’t already know Collection.Index exists, how would they be expected to learn of it? And if they didn’t know it must be Comparable how would they learn that?</div><div><br></div><div>Also, are there any semantic requirements on Collection.Index, for example is it required that “idx < index(after: idx)” must evaluate to true for any valid index “idx”?</div><div><br></div><div>• • •</div><div><br></div><div>On a somewhat related note, the “indices” property of Collection has a discussion section visible by option-clicking in Xcode or by looking at the <a href="https://developer.apple.com/documentation/swift/collection/1641719-indices">documentation for it</a> on <a href="http://developer.apple.com">developer.apple.com</a>.</div><div><br></div><div>And that discussion recommends against iterating over “indices” when mutating a collection, because “indices” could hold a strong reference to the collection and thus create an unexpected copy. Instead one should manually advance from startIndex to endIndex in a while loop.</div><div><br></div><div>Now, this is at least documented, but perhaps it should be made more prominent? It seems to me that if “for i in c.indices” represents a performance pitfall then it should be regarded as an attractive nuisance.</div><div><br></div><div>Nevin</div></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-users mailing list</span><br><span><a href="mailto:swift-users@swift.org">swift-users@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-users">https://lists.swift.org/mailman/listinfo/swift-users</a></span><br></div></blockquote></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-users mailing list</span><br><span><a href="mailto:swift-users@swift.org">swift-users@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-users">https://lists.swift.org/mailman/listinfo/swift-users</a></span><br></div></blockquote></div></body></html>