- bool ^= true:
for (int i = 0; i < X; i++)
{
myitem = (checkedDB ^= true) ? cleanItem : dirtyItem;
}
cleanItem dirtyItem, checkedDB , .
The advantage of using checkedDb ^= trueover checkedDB = !checkedDBis that it is clear that you wanted to change checkedDBand it was no coincidence that the comparison was wrong ==.
Since you did not specify the language, I cannot say for sure whether your language will allow assignment in the conditional part of the ternary operator.
source
share