Every now and then, if the code I posted is especially bad, I'll see quite a few readers question if the code is real. Today I'm expecting to read a lot of those comments. Heck, the first time I saw this code pattern submitted, I thought it was a fake. Seriously, no one would really do this in production code.
The second time it came in, I figured the same thing: just another guy making up a clever submission. By the third or fourth submission, I was pretty convinced that this pattern was real, but I was reluctant to post it because no one else would believe it. And then I spotted it myself. In the wild. On real, production code.
try { int idx = 0; while (true) { displayProductInfo(prodnums[idx]);
idx++; } } catch (IndexOutOfBoundException ex) { // nil }
My apologies to those who submitted code like this in; I thought you were making it up. I'd give you credit, but I discarded your submission assuming it was fake. If it's any consolation, I now share your pain.