I would suggest enumerate only for types that are subscriptable and that it be defined as their (index, value) set that iterates in the collection's indices order. IE:<div><br></div><div> for index in collection.indices {</div><div> let value = collection[index]</div><div> ...</div><div> }</div><div><br></div><div>and</div><div><br></div><div><div><font size="2"><span style="background-color:rgba(255,255,255,0)"> for (index, value) in collection.enumerate {</span></font></div><div><font size="2"><span style="background-color:rgba(255,255,255,0)"> ...</span></font></div><div><font size="2"><span style="background-color:rgba(255,255,255,0)"> }</span></font></div><div><br></div>are equivalent. <br><div><br></div><div>With the above definition I would suggest a name change to entries, since a Dictionary's keys are not necessarily numbers, hence enumerate is misleading. </div><div><br></div><div>Nothing for Set since it isn't subscriptable. <span></span><br><br>On Saturday, 16 April 2016, Brent Royal-Gordon <<a href="mailto:brent@architechies.com">brent@architechies.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> I would suggest an alternative; changing Range so that it is indexed like an array, an Int from 0 to count - 1. Such that aRange[index] is defined as start + index * stride. This will eliminate the problems with enumerate. A Range's generic type would be constrained to be an Arithmetic type, see extended floating point proposal.<br>
<br>
That papers over the problem for Slice/Range specifically, but it doesn't fix it for types with non-integer indices, like Dictionary and Set. enumerate() is not meant to be used for the purpose to which it is usually put. </blockquote></div></div><br><br>-- <br>-- Howard.<br>