Returns a subsequence from the start of the collection through the specified position.
- iOS 7.0+
- macOS 10.9+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
- Xcode 8.0+
The index of the last element to include in the resulting subsequence.
endmust be a valid index of the collection that is not equal to the
A subsequence up to, and including, the
The resulting subsequence includes the element at the position
end. The following example searches for the index of the number
40 in an array of integers, and then prints the prefix of the array up to, and including, that index:
prefix(through:) method is equivalent to using a partial closed range as the collection’s subscript. The subscript notation is preferred over