endIndex
The position one greater than the last valid subscript argument.
Declaration
@MainActor @preconcurrency var endIndex: Int { get }Discussion
When you need a range that includes the last element of an array, use the half-open range operator (..<) with endIndex. The ..< operator creates a range that doesn’t include the upper bound, so it’s safe to use with endIndex.
If the array is empty, endIndex is equal to startIndex.