Generic Operator

+=(_:_:)

Appends the elements of a sequence to a range-replaceable collection.

Declaration

static func += <Other>(lhs: inout Data, rhs: Other) where Other : Sequence, Self.Element == Other.Element

Parameters

lhs

The array to append to.

rhs

A collection or finite sequence.

Discussion

Use this operator to append the elements of a sequence to the end of range-replaceable collection with same Element type. This example appends the elements of a Range<Int> instance to an array of integers.

var numbers = [1, 2, 3, 4, 5]
numbers += 10...15
print(numbers)
// Prints "[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]"

Complexity: O(m), where m is the length of the right-hand-side argument.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software