---
title: "append(contentsOf:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/array/append(contentsof:)-9foli"
---

# append(contentsOf:)

Adds the elements of a sequence or collection to the end of this collection.

## Declaration

```swift
mutating func append<S>(contentsOf newElements: S) where S : Sequence, Self.Element == S.Element
```

## Parameters

- `newElements`: The elements to append to the collection.

## Discussion

Discussion The collection being appended to allocates any additional necessary storage to hold the new elements. The following example appends the elements of a Range<Int> instance to an array of integers: var numbers = [1, 2, 3, 4, 5] numbers.append(contentsOf: 10...15) print(numbers) // Prints "[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]" note: O(m), where m is the length of newElements.

## See Also

### Combining Arrays

- [append(contentsOf:)](swift/array/append(contentsof:).md)
- [+(_:_:)](swift/array/+(_:_:)-6h58k.md)
- [+(_:_:)](swift/array/+(_:_:)-n33n.md)
- [+(_:_:)](swift/array/+(_:_:).md)
- [+(_:_:)](swift/array/+(_:_:)-9fm5l.md)
- [+=(_:_:)](swift/array/+=(_:_:)-676ib.md)
- [+=(_:_:)](swift/array/+=(_:_:).md)
