I'm thinking things like a basic text search function where you might want to not only say that it is found but where in the document. Returning 0 gives the false impression it is found in the string.
The only time I feel like it could return 0 is if the string it was looking the index up in itself was empty. Even then, it is still searching for nothing and finding an index.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I'm thinking things like a basic text search function where you might want to not only say that it is found but where in the document. Returning
0
gives the false impression it is found in the string.The only time I feel like it could return
0
is if the string it was looking the index up in itself was empty. Even then, it is still searching for nothing and finding an index.