Hi. Sorry for the late reply. I have been geeking out on WWDC.
So. index(_:offsetBy:) takes an IndexDistance type. You can’t just pass an Int in there. IndexDistance is a SignedInteger and Index is an Int. That is a convenient way to convert between the types. Actually I am not aware of any other way to do it. Do you know of one?
extension RandomAccessCollection where Index == Int {
var random: Iterator.Element {
precondition(!isEmpty)
let index: Int = numericCast(startIndex + (endIndex-startIndex).randomUniform)
return self[index]
}
}