4 ms·
Ranges are usually specified with the lower bound being inclusive and the upper bound exclusive. In this case [fromIndex, toIndex) So if the range goes to the
by ddlatham 10y ago
Ranges are usually specified with the lower bound being inclusive and the upper bound exclusive. In this case [fromIndex, toIndex)
So if the range goes to the end of the arrary, then you would expect toIndex == arrayLen and the check is correct.
- mannykannot 10y agoIs that consistent with the first condition in the function? This function accepts fromIndex == arrayLen if toIndex == arrayLen. Of course, there may be a precondition that rules it out, or it might be an acceptable postcondition.
- thaumasiotes 10y agoUnder the scheme described, fromIndex == toIndex would be a stretch of 0 array elements, so it wouldn't really matter whether fromIndex and toIndex pointed into the array at all.
- mannykannot 10y agoDoh! - thanks.