I would like to do this in one line (C programming language):
int x = index >> 8;
int y = x < 10 ? x+1 : x+2;
Is it possible? How do I reference to value before ? sign, if I don’t have it stored in separate integer?
"int y = (index >> 8) < 10 ? [what]+1 : [what]+2;"
You simply need to repeat the expression:
It’s not very nice, or readable, so I don’t get why you must do it this way. There’s no built-in way in the language to reference the expression before the
?. Since expressions can have side-effects in C, it would be quite hairy if there was.