Generic Initializer

init(_:)

Creates a new instance of a collection containing the elements of a sequence.

Declaration

init<S>(_ elements: S) where S : Sequence, Self.Element == S.Element

Parameters

elements

The sequence of elements for the new collection.

See Also

Creating an Array

init()

Creates a new, empty array.

init<S>(S)

Creates an array containing the elements of a sequence.

init(repeating: Element, count: Int)

Creates a new array containing the specified number of a single, repeated value.