This is because the ternary operator (?:
) is left associative so this is how it's getting evaluated:
((1 == 1) ? "one" : (1 == 2)) ? "two" : "three"
So 1 == 1
-> TRUE
means that then it's:
"one" ? "two" : "three"
And "one"
-> TRUE
so the output will be:
two