4 ms·
Not so much "error reporting" as "there is no meaningful return value" for a position in a string -- if it wasn't found, it doesn't have a position. If you use
by flqn 3y ago
Not so much "error reporting" as "there is no meaningful return value" for a position in a string -- if it wasn't found, it doesn't have a position.
If you use either Optional or Result you don't need to choose a special value like -1 to be your "invalid string position" case which could be used incorrectly.
I'd argue it's largely stylistic for this example, especially so outside of functional programming niches.
- skrebbel 3y agoIt nevertheless in no way solves the problem that the article is about.