3
I recently came across an assignment to a boolean variable as follows:
bool varTeste = (varEntrada == 100) ? true : false;
I know this is the same as the code below:
bool varTeste = (varEntrada == 100);
The question is whether there is a difference in performance/processing or the ? true : false
is just unnecessary?
Even if there is a small difference you would need to perform this operation millions of times to become relevant. Most of the time the clarity of the code is much more important than these details, try to choose the form that makes the code more readable and easy to understand
– Rodrigo Sidney