Skip to content
Swift

Array API Reference

Swift's Array<T> — an ordered, random-access collection of elements, backed by contiguous storage.

By EZ4Code Team

Array

An ordered, random-access collection. Arrays are value types in Swift.

Array.append(_ newElement: Element)

Adds a new element at the end of the array.

Returns: Void

Array.count -> Int

The number of elements in the array.

Returns: Int

Array.remove(at: Int) -> Element

Removes and returns the element at the specified position, shifting subsequent elements.

Returns: Element

Array.contains(_ element: Element) -> Bool

Returns true if the array contains an element equal to the given value.

Returns: Bool

Array.map<T>(_ transform: (Element) throws -> T) rethrows -> [T]

Returns an array containing the results of mapping the given closure over the sequence's elements.

Returns: [T]

Array.filter(_ isIncluded: (Element) throws -> Bool) rethrows -> [Element]

Returns an array containing the elements that satisfy the given predicate.

Returns: [Element]

Array.sorted(by: (Element, Element) throws -> Bool) rethrows -> [Element]

Returns the elements of the sequence, sorted using the given comparison closure.

Returns: [Element]

Array.joined(separator: String) -> String

Returns a string containing the elements of the sequence, separated by the given separator.

Returns: String

More Swift API References