mirror of
https://github.com/samsonjs/SwiftBatteries.git
synced 2026-03-25 09:25:51 +00:00
Index.Distance has to be IntMax
This commit is contained in:
parent
44dfb748ee
commit
3f0daeded7
1 changed files with 3 additions and 3 deletions
|
|
@ -49,9 +49,9 @@ public extension CollectionType where Index: RandomAccessIndexType {
|
|||
guard !isEmpty else {
|
||||
return nil
|
||||
}
|
||||
let max = Int(count.toIntMax())
|
||||
let n = randomInt(max) - 1
|
||||
return self[startIndex.advancedBy(n)]
|
||||
let n = Int(count.toIntMax())
|
||||
let i = startIndex.advancedBy(Index.Distance(IntMax(randomInt(n) - 1)))
|
||||
return self[i]
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue