I was not sure what to look for - but I was looking for an elegant way, if possible, to structure an if statement that uses two Boolean values that can easily print all four possibilities.
Variables
bool a = true;
bool b = true;
I was not sure if there was a best practice in terms of checking both negativity and continuation, etc.
A very hasty written example:
if(!a && !b)
{
//Output (-,-)
}
else
{
if(a || b)
{
if(a)
{
//Output (+,-)
}
else
{
//Output (-,+)
}
}
else
{
//Output (+,+)
}
}
Sorry for all the gullwings ({}) I'm a bit of a formatting junkie. Anyway - thanks for any suggestions!
source
share