2 ms·
0, obviously. It's the only consistent choice. This is only confusing if you're thinking of taking single elements from an array, rather than thinking in terms
by o11c 3y ago
0, obviously. It's the only consistent choice.
This is only confusing if you're thinking of taking single elements from an array, rather than thinking in terms of slices of arrays. Slicing also makes it obvious why we must use half-open ranges and 0-based indexing.
The only minor gotcha is that, when doing a request for "find all non-overlapping" or "find next strictly after", you have to increment the search index by 1 even though the size of the match is 0. ("find all overlapping" or "find next starting after" always increment by 1 and ignore the size of the match).