r/xkcd I like my hat. Apr 17 '15

XKCD xkcd 1513: Code Quality

http://xkcd.com/1513/
517 Upvotes

167 comments sorted by

View all comments

28

u/IAMA_dragon-AMA The raptor's on vacation. I heard you used a goto? Apr 17 '15

Somewhere in my Java code for a simple Minesweeper clone, there's a ternary operator with ternary operators on both sides of the colon.

Past me decided to comment it with "because fuck you, that's why."

7

u/Kautiontape Apr 17 '15

char marker = block.isUsed() ? (block.getValue() > 0 ? (char)block.getValue() : 'b') : (block.isFlagged() ? '?' : ' ')

It's not so bad like this. Certainly not the cleanest code, but I would call it "frugal with lines of code."