Krupski:
Yes indeed. The question mark denotes the thing that happens if "X" is true and the colon denotes the thing that happens if "X" is false.Here's an example (pseudo code):
what_is_larger = (moon < sun) ? "The sun" : "The moon"
The test condition is "moon less than sun". Since the moon is smaller than the sun, "(moon < sun)" evaluates to "TRUE". Therefore, the string after the QUESTION MARK is the one that is placed into the variable "what_is_larger".
I could also write it this way:
what_is_larger = (moon > sun) ? "The moon" : "The sun"
Since, in this case, "(moon > sun)" is FALSE, the string after the COLON is placed into the variable "what_is_larger".
Got it?
@Krupkski,@AWOL,
Thank you for your help, it makes perfect sense. The above explanation was very helpful. Is there any reason (other than succinctness) to use this as opposed to an if-else statement?