我无法继续使用我的应用程序,也无法测试运行它,因为我的代码中有问题,我不知道如何修复!这是代码:
import Foundation
extension Array {
mutating func shuffle() {
if count < 2 { return }
for i in 0..<(count - 1) {
let j = Int(arc4random_uniform(UInt32(count - i))) + i
customSwap(a: &self[i], b: &self[j])
}
}
}
func customSwap<T>(a:inout T, b:inout T) {
let temp = a
a = b
b = temp
}
Run Code Online (Sandbox Code Playgroud)