I was reviewing some third-party code earlier and came across this little gem (trimmed down to the important bit)…
bool x = y == z ? true : false;
I have wracked my brain and can not come up with a situation in which I would need the ternary operator ?:
to convert a boolean into a boolean as tested by an operator ==
that already returns a boolean value. Maybe it avoids some kind of compiler warning regarding mixing =
and ==
.