gpt4 book ai didi

swift - Swift 3 中的 Int 和 Self.Index.Distance 冲突

转载 作者:搜寻专家 更新时间:2023-10-31 22:44:35 24 4
gpt4 key购买 nike

<分区>

我有:

extension MutableCollection where Index == Int { // shuffle elements of self in place

mutating func shuffleInPlace() {

if count < 2 { return } // empty and single-element collections don't shuffle

for i in 0 ..< count - 1 {
let j = Int( arc4random_uniform( UInt32( count - i ) ) ) + i
guard i != j else { continue }
swap( &self[ i ], &self[ j ] )
...

...

我收到错误:

Binary operator Binary operator '..<' cannot be applied to operands of type 'Int' and 'Self.IndexDistance'

有谁知道如何解决这个问题?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com