相关疑难解决方法(0)

随机阵列swift 3

如何将以下功能转换为swift 3?目前收到Binary operator '..<' cannot be applied to operands of type 'Int' and 'Self.IndexDistance'错误.

extension MutableCollection where Index == Int {
  /// Shuffle the elements of `self` in-place.
  mutating func shuffleInPlace() {
    // empty and single-element collections don't shuffle
    if count < 2 { return }

    for i in 0..<count - 1 { //error takes place here
      let j = Int(arc4random_uniform(UInt32(count - i))) + i
      guard i != j else { continue }
      swap(&self[i], &self[j])
    } …
Run Code Online (Sandbox Code Playgroud)

swift swift3

29
推荐指数
3
解决办法
1万
查看次数

标签 统计

swift ×1

swift3 ×1