Re: reading an abused ternary conditional operator
Lew wrote:
EricF wrote:
In article <5l7j045eet7qftd7s817arir66oek0obn0@4ax.com>, Roedy Green
<see_website@mindprod.com.invalid> wrote:
On Sat, 19 Apr 2008 07:25:48 GMT, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :
You are completely correct. Nobody should WRITE such code, but
everyone should be able to decode it in an emergency.
On the other hand, people who can decode that in their sleep probably
don't have enough real work to do.
I think these sorts of questions on tests are silly. It is not
necessary to be able to do it without reading up or doing an
experiment.
Real life often throws maintenance tasks at a programmer where the
"abused" ternary operator would be the least of the problems.
Two points:
If you cannot parse the "abused" ternary operator, you don't know Java.
Quit whining that "people shouldn't do that". Can you read it? If not,
don't call for the author to be fired, quit yourself.
The other point is that it is NOT a useless skill. You will run into
crap like that. If you can't handle it, go back to asking, "Would you
like fries with that?"
I think there is a difference between being able to deal with it in real
life, and being able to deal with it in a timed, closed-book test.
In order to answer this question I had to look in the JLS to check the
grouping rule for ?:. I just don't deal with nested ternaries often
enough to remember it. On the other hand, I do need the specifics of how
an expression behaves often enough to know exactly where to look.
In real life, I would have had no problem. In a timed, closed-book test,
I would have had to guess the grouping order.
Patricia