Returns a subsequence from the start of the collection up to, but not including, the specified position.
- Xcode 8.0+
- Swift Standard Library
The “past the end” index of the resulting subsequence.
endmust be a valid index of the collection.
A subsequence up to, but not including, the
The resulting subsequence does not include 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, but not including, that index:
Passing the collection’s starting index as the
end parameter results in an empty subsequence.
prefix(up method is equivalent to using a partial half-open range as the collection’s subscript. The subscript notation is preferred over