2

Since updating my Xcode I have run into this problem with a piece if code that I got from a Udemy Tutorial.

Here is the code:

 func shuffle<C: MutableCollection where C.Index == Int>( list: C) -> C {
    var list = list
    let total = list.count

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

    return list
}

and this line:

for i in 0..<(total - 1) {

brings this error:

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

Can someone help me with this?

JamesG
  • 1,552
  • 8
  • 39
  • 86

0 Answers0