The remove() method removes an element from the array at the specified index.
Example
remove() Syntax
The syntax of the array remove() method is:
array.remove(at: index)
Here, array is an object of the Array class.
remove() Parameters
The remove() method takes only one parameter:
- index - index of the element to remove
remove() Return Value
- returns the element that was removed from array
Example: Swift Array remove()
Output
Before Removing: ["Swift", "C", "Objective-C"] After Removing: ["Swift", "C"] Removed Element: Objective-C
Here, we have removed "Objective-C" from the languages array. The removed element is stored in the removed variable.