Answers for "swift array drop last"

1

pop last element array swift

// Initialize the Array
var a = [1,2,3]

// Remove last item
let lastItem = a.removeLast()

print(lastItem)
print(a)
Posted by: Guest on March-17-2020
0

How to remove the last item from an array in swift

var x = [2, 4, 6, 7]
x.popLast()

print(x.count)
// output : 3
Posted by: Guest on June-16-2021

Code answers related to "swift array drop last"

Code answers related to "Swift"

Browse Popular Code Answers by Language