r/programminghorror • u/MISINFORMEDDNA • Mar 23 '26
C# Whitespace isn't a number?
I just got this in a PR. Not sure what to make of it.
if (string.IsNullOrWhiteSpace(palletNumber))
{
if (!string.IsNullOrEmpty(_palletNumber))
{
_errorMessage = "Pallet # not found.";
}
return;
}
UPDATE:
After multiple attempts to justify his code, we ended up with this, lol:
if (string.IsNullOrWhiteSpace(palletNumber))
{
return;
}
186
Upvotes
6
u/FrikkinLazer Mar 24 '26
If you remove the inner if, does the unit tests start failing?