How can I use the ternary ? : condition to perform multiple operations, if expression is true/false?
? :
wbsource = (exp) ? (Do one thing) : (Do secon
If this was c you'd be OK thanks to the "comma operator":
c
int b; int a = (1==1) ? (b=6, somemethod(), 1) : (b=7, 2);
Here b will be set to 6, somemethod will be called and then a is set to 1.
b
somemethod
a
Thankfully that was one feature that was not ported over, use if..else it's much clearer.
if..else