/*To remove all items from an array, use the removeAll method.*/
var animalArray: [String] = ["Dog", "Cat", "Fish", "Owl" ]
animalArray.removeAll()
//animalArray is now empty.
/*Keeping the capacity of the array*/
animalArray.removeAll(keepCapacity: true)
//animalArray is now empty but the capacity is kept at 4.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.