Swift Array Methods

Swift has a lot of Array methods that allow us to perform different operations on array elements. For example, the contains() method checks if the specified element is present in the array or not.

In this reference, you will find various array methods that are available in Swift.

Swift Array append()

inserts a new element at the end of the array

Swift Array capacity

returns number of elements

Swift Array contains()

checks whether the element is present or not

Swift Array dropFirst()

drops the first element

Swift Array dropLast()

drops the last element in the array

Swift Array first

returns the first element of array

Swift Array insert()

inserts an element to the array

Swift Array joined()

return string with elements separated by separator

Swift Array last

returns the last element of the array

Swift Array min()

returns the minimum element in the array

Swift Array remove()

removes an element from the array

Swift Array removeAll()

removes all the elements from the array

Swift Array removeSubrange()

removes elements present in specified indices

Swift Array reverse()

reverse the order of an array

Swift Array sort()

sorts the elements of an array in a specific order

Swift Array swapAt()

swaps two elements in an array

Swift Array allSatisfy()

returns Bool based on given condition

Swift Array count

returns the total number of elements present

Swift Array filter()

returns elements that satisfy given condition

Swift Array isEmpty

checks if the array is empty or not

Swift Array map()

transforms the array

Swift Array max()

returns the maximum element in the array

Swift Array prefix()

returns specified number of elements from first

Swift Array removeLast()

removes the last element from the array

Swift Array shuffle()

shuffles all the elements of an array

Swift Array suffix()

returns specified number of elements from last