Pop last item from array

 Problem

I have an Array and want to pop (delete and return) its last element.



 Recipe


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

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

print(lastItem)
print(a)
		
				

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)

 

 Playground