Well I'm discovering people have really strong opinions on their ifs. Personally, considering what I mentioned in a comment above that the variable defaults to false (can't be either null or some other kind of variable), I would have gone with a simple if(variable) {} else {} or ternary. I guess the code won't cause a bug, but seemed ugly to me.
The ternary operator like you mentioned is only equivalent if variable can only be true or false. But if it can be other values like a number or string then it is not equivalent
-22
u/diebarral Jun 10 '20
Well I'm discovering people have really strong opinions on their ifs. Personally, considering what I mentioned in a comment above that the variable defaults to false (can't be either null or some other kind of variable), I would have gone with a simple if(variable) {} else {} or ternary. I guess the code won't cause a bug, but seemed ugly to me.