Required Instance Methodswift 6.0.1Swift

    append(_:)

    Adds an element to the end of the collection.

    mutating func append(_ newElement: Self.Element)

    Parameters

    newElement

    The element to append to the collection.

    If the collection does not have sufficient capacity for another element, additional storage is allocated before appending newElement. The following example adds a new number to an array of integers:

    var numbers = [1, 2, 3, 4, 5]
    numbers.append(100)
    
    print(numbers)
    // Prints "[1, 2, 3, 4, 5, 100]"

    Other requirements

    View members

    Hide members

    This section is hidden by default because it contains too many (17) members.

    Type members

    Instance members

    Citizens in Swift

    Default implementations