If switch
< if-then-else
and if-then-else
== ternary
, then switch
< ternary
.
Comparisions using ternary operator vs if else vs switch case (Performance)
-
24-06-2023 - |
Вопрос
I was searching for if-else vs ternary operator vs switch case but could not find any post with all the three comparisons. However, I came across some good posts and found that switch-case is faster than if-else. You may check the below one:
Then I came across some posts which said that there is no performance difference between if-else and the ternary operator. One of the most relevant posts is the following:
However, I did not find any relevant posts for switch-case vs ternary operator.
So, I just want to know if I can conclude that switch case is faster than both ternary operator and if-else?
I know this is a silly question but I want to know the answer.
Решение
Не связан с StackOverflow