Thanks I appreciate it. My coding language is limited to c, java and Python, and a bit of others but I've never encountered it before.
Most project design style documents prohibit its use.
It's way too easy to screw things up if you use it for anything but the simplest of expressions. Anything you can do with a ternary you can do with an if/else, so it's not a required operator by any means. In this case, since you're limited in what you can put in the formula box, it does come in handy.
My personal rule(s) of thumb:
1) Everything must be on one line, no compound expressions.
Technically you could put a whole code block for the "true" and "false" results - you can even put another ternary operator expression for each, and give them their own code blocks if you're submitting something for an 'obfuscated code' contest.
2) It must be immediately apparent what's going on.
In practice I'll use it for a return value, where the true and false statements are a single word: "return foo?bar1:bar2", or sometimes as a parameter in order to pass one of two variables:"foo(bar?var1:var2)". I think I may have used it one place to call a combat skill based on whether or not the attacker was an actor: "(actor?) ? method1(args):method2(args)"
If there is ANY possible confusion about the line, write it as an if/else. If you feel it needs extra commenting to explain it, write it as an if/else. If you're writing code with plans to distribute it to other people and have them understand it - you guessed it, write it as an if/else.
It's really a relic of a time back when programmers needed to write "terse" code, because every byte counted.
Classic example (using C):
example 1:
Spoiler
strcpy (s, t)char *s, *t;{ while ((*s=*t) !='\0'){ s++; t++; }}
Example 2:
Spoiler
strcpy(s, t)char *s, *t;{ while (*s++ = *t++);}
Both of those do exactly the same thing, but the first example was considered very wasteful and inefficient.
The second example, being much more terse, was considered far better coding style.
Today, we're somewhere in the middle of the two extremes, for the most part. Make your code terse, but readable, and be liberal with your comments. The person updating it someday may be you, and if you haven't seen it for a year or more it may as well have been written by somebody else. If you are writing for somebody else... I don't think I've ever heard somebody throw a fit because code was overly commented.