Creates an array containing the elements of a sequence.
- Xcode 9.0+
- Swift Standard Library
The sequence of elements to turn into an array.
You can use this initializer to create an array from any other type that conforms to the
Sequence protocol. For example, you might want to create an array with the integers from 1 through 7. Use this initializer around a range instead of typing all those numbers in an array literal.
You can also use this initializer to convert a complex sequence or collection type back to an array. For example, the
keys property of a dictionary isn’t an array with its own storage, it’s a collection that maps its elements from the dictionary only when they’re accessed, saving the time and space needed to allocate an array. If you need to pass those keys to a method that takes an array, however, use this initializer to convert that list from its type of
Lazy to a simple