Humor
Totally Valid
[ad_1]
Greg's co-worker really wanted to make sure that a variable was correctly set to true or false. So they did this:
if (isValid == true)
{
isValid = true;
}
else
{
isValid = false;
}
If isValid
is true, set it to true, otherwise set it to false. isValid
is a boolean in C#, so the only options it could have are true
and false
.
The real WTF is that in languages with truthiness, this code may actually be useful- converting a falsey value to a literal false. But in C#, this is both useless and stupid.
[Advertisement]
Otter – Provision your servers automatically without ever needing to log-in to a command prompt. Get started today!
Otter – Provision your servers automatically without ever needing to log-in to a command prompt. Get started today!
[ad_2]
Remy Porter
Source link
