I searched for if-else vs trernary operator vs switch case, but could not find a message with all three comparisons. However, I came across some good messages and found that the switching register is faster than if-else. You can check below:
Why switch faster than if
Then I came across some messages that said that there is no performance difference between the if-else and the ternary operator. One of the most important messages is the following:
ternary operator versus if statement: question about good condition?
However, I did not find any relevant messages for the switch-case vs trernary statement.
So, I just want to know if I can conclude that the switch case is faster than both ternary operators, and if-else?
I know this is a stupid question, but I want to know the answer.
source
share