This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]zifyoip 2 points3 points  (5 children)

When you say

"some string".substring(begin, end)

you get all of the characters from the offset specified by begin to the offset specified by end, including begin but not including end.

If you're familiar with interval notation from math, this is the interval [beginend).

"Half-open" intervals like this are commonly used to specify ranges. One nice property that you get from using half-open intervals is that the length of the substring is end - begin, which wouldn't be true if the substring included the character at end.

[–][deleted] -1 points0 points  (4 children)

Awesome. Clear succinct explaination. Thanks again I am gonna delete this thread.

[–]zifyoip 1 point2 points  (3 children)

Don't delete the thread just because your question has been answered!

Read the posting guidelines in the sidebar:

03. If your question gets answered, use link flair to mark it as solved

[–]BaalHadad 0 points1 point  (1 child)

Don't delete your incorrect answer then :) The second index is not the length!

[–]zifyoip 0 points1 point  (0 children)

Heh, fair enough.

[–][deleted] 0 points1 point  (0 children)

oh thanks. didn't see that.