I’ve looked around a little and haven’t found an equivalent question.
Is this bad coding practice? I can read it easily, but is it too cryptic for someone reading the code?
bool? testBool = null;
string result;
result = (testBool ?? false ? "Yes" : "No");
Edit: My apologies to everyone for some horrible code! Here is a working example..
I’m a little overwhelmed by the speed of the replies. I was going to delete this and do it right, but already had 4 replies!
I’d add parens so clarify what’s going on — ie.
With that, I’d be fine with it. Without it, I had to study it for a bit to figure out what was going on (if it even compiles — I don’t know the order of operations off the top of my head for ?: vs. ??)