- Home /
This question was
closed Apr 15, 2014 at 04:06 PM by
Flint Silver for the following reason:
The question is answered, right answer was accepted
Question by
Flint Silver · Mar 24, 2014 at 09:08 PM ·
syntaxdifferenceif-else
Difference between ternary Operator and If else
So, what are the difference between the two statement write above?
The syntax is the only difference I realize so far.
Comment
Best Answer
Answer by SkaredCreations · Mar 24, 2014 at 09:45 PM
Yes it's just the syntax, no difference or overhead in performance, just readability vs line count number.
I thought there were some other difference... Thank for reply
only major difference is that ?: operator readability is not that great.
In terms of performance, at a million runs on each the diff is just 300 - 400 milli seconds.
There is a performance difference, namely that the ternary operator is faster, but the difference is quite small so your primary concern should be readability.