This is due to the fact that the ternary operator ( ?:) is left associative , so this is how it is evaluated:
((1 == 1) ? "one" : (1 == 2)) ? "two" : "three"
So, 1 == 1→ TRUEmeans then that:
"one" ? "two" : "three"
And "one"→ TRUE, so the output will be:
two
source
share