4 ms·
> If the first number in the range is a valid index into the string then you'll get something back, and if it isn't you can't get anything back so you have to g
by wavemode 2y ago
> If the first number in the range is a valid index into the string then you'll get something back, and if it isn't you can't get anything back so you have to get back a nil
But, 3 is not a valid index into a string of 3 characters. By your criteria, "abc"[3] correctly returns nil. Whereas "abc"[3,1] returns ""
The language designers really just did not think this through.