I wrote a function to exchange the array elements. But it returns error: Playground execution failed: :21:5: error: '@lvalue $T8' is not identical to 'T' data[i] = data[j] ^ :22:5: error: '@lvalue $T5' is not identical to 'T' data[j] = temp ^
The code is as follows:
func exchange<T>(data: [T], i:Int, j:Int) {
let temp:T = data[i]
data[i] = data[j]
data[j] = temp
}