3 ms·
Hm Unless your parsePort returns a specialized type which then can be enforced by the compiler, and all your other APIs use the specialized representation, it'
by WesolyKubeczek 3y ago
Hm
Unless your parsePort returns a specialized type which then can be enforced by the compiler, and all your other APIs use the specialized representation, it's sort of "six of one, half a dozen of the other" situation because if you're throwing your strPort around, you'll be parsing it again and again and again.
And I can achieve what you are showing me just the same by putting my guard clause up the stack, closer to the main program or whatever.
Not all data is so clear cut, your guard clause may be guarding against a numeric struct member whose value is out of range for this one function to operate.
Which is why I usually have a few different wrenches for each size of nut I may encounter. Not dunking on your approach, let a hundred flowers bloom and all that.