With the ternary operator a boolean expression is evaluated, if it is true the code before the colon is executed if it is false the code after the colon is evaluated.
(<boolean expression> ? "if true do this" : "if false do this").
It may be easier to see the answer to the nested example you posted if you draw it as a decision tree.
if the expression is true go down the left subtree, if false go down the right
Hope this helps,
"If the facts don't fit the theory, get new facts" --Albert Einstein