How to replace elements by indexes in array with Swift

1 Answer

0 votes
var arr = [1, 2, 3, 4, 6, 7, 8, 9]

print(arr)

arr[0...3] = [10, 20]

print(arr)


  
   
/*
run:

[1, 2, 3, 4, 6, 7, 8, 9]
[10, 20, 6, 7, 8, 9]
  
*/
 

 



answered Sep 2, 2020 by avibootz
...