4 ms·
What reason could there possibly be for looking for an empty string?
by bryancoxwell 3y ago
What reason could there possibly be for looking for an empty string?
- tharkun__ 3y agoBecause the string you are trying to find is in some variable which at runtime in some cases for some reason happens to be an empty string and you don't (want to) special case this and just "let it work by itself"?
- fasterik 3y agoThere are many cases where a user-provided string is passed to the string API. Generally the programmer should handle empty strings as a special case, but when they don't the API needs to return something.
- bryancoxwell 3y agoThanks!
- ajuc 3y agoAvoiding the need to special-case empty input.
- hermitcrab 3y agoIs it a sensible thing to do: No. Will users do it anyway: Yes. We have to handle all possible values the user can provide.