Wow, not sure how I missed that. I think inclusive ranges are easier to understand here.
Changed to
"abcdefg"[4..-1]
returns "efg"
, since e
is the character at index f
, and f
is the character at index -1
, the last character. Halfway ranges also work, so "abcdefg"[..-2]
returns all but the last character, and "abcdefg"[3..]
returns everything from index 3
on