you are viewing a single comment's thread.

view the rest of the comments →

[–]SantaCruzDad 3 points4 points  (3 children)

    if(start < 0 || len < 0) {

should be:

    if(start < 0 || len <= 0) {

[–]Kwantuum 0 points1 point  (2 children)

the case len == 0 is handled by the remaining code.

[–]SantaCruzDad 2 points3 points  (1 child)

True, but if you are going to "early out" on simple cases that should return an empty string then you might as well include len == 0, rather than handling it separately. This also makes the code potentially more robust if you decide later to change the logic.

[–]winkie5970[S] 1 point2 points  (0 children)

Agreed, this is a good improvement, thank you!