How to remove the first element from an array and return the element in Swift

1 Answer

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

let first = arr.removeFirst()

print(first)
print(arr)
 

  
  
/*
run:

3
[6, 1, 8, 4]
 
*/

 



answered Sep 2, 2020 by avibootz

Related questions

3 answers 317 views
2 answers 283 views
1 answer 139 views
2 answers 126 views
1 answer 78 views
...