Instance MethodSwift5.9.0

    remove(at:)

    Removes and returns the element at the specified position.

    @discardableResult mutating func remove(at index: Int) -> Element

    Parameters

    index

    The position of the element to remove. index must be a valid index of the array.

    Returns

    The element at the specified index.

    All the elements following the specified position are moved up to close the gap.

    var measurements: [Double] = [1.1, 1.5, 2.9, 1.2, 1.5, 1.3, 1.2]
    let removed = measurements.remove(at: 2)
    print(measurements)
    // Prints "[1.1, 1.5, 1.2, 1.5, 1.3, 1.2]"