Probably what the orignal intent, other than just being a smart ass, is to try and help a bad compiler with the index multiplies. A good optimizer will fix both code sets to be the same or very close. The first example might save a stack save/load if you have a lot of registers to play with.
The Ewww factor is very high, enough to send the person back to beginning typing school to learn to use more than 2 fingers.
If you're going to try a "reductio ad absurdum", why stop short? Might as well go all the way to make it truly absurd.
Of course it will compile --- it'll even work. Which does beg the question: why the "Ewww"?
Seriously, though, nobody forces anyone to write code like that first snippet (much less mine), and rather few programmers would. Most people would only consider the conditional operator for the right-hand side of an assignment, or function arguments, i.e. for making rvalues, not lvalues.
But then again, in a pinch the compiler might, for some strange reason, compile denser/faster code from it, and if that saves the day, there's nothing wrong with having that option, is there?
And if you're really uncomfortable with that rather dense notation, there are always in-between options like those shown by others here. Following the principle of separating things that differ from things that don't (in other words: don't copy-paste, concentrate!), I would lean towards this one:
I think if you are going to use the conditional operator you *must* nest them at least nine deep. I did that once about twenty years ago, the boss emitted steam.
You can probably rigorously prove that any if-else construct involving assignment to a single variable can be represented with nested C ternary operators.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.