How to replace N elements with Y new elements in array at index range with Swift

1 Answer

0 votes
var arr = [5, 6, 2, 0, 1, 8]

print(arr)

arr[0...2] = [100, 200]

print(arr)
 
 
 
 
/*
run:
 
[5, 6, 2, 0, 1, 8]
[100, 200, 0, 1, 8]
 
*/

 



answered Nov 9, 2020 by avibootz
...