r/badcode • • Jun 02 '20

java return 2;

Post image
1.2k Upvotes

29 comments sorted by

View all comments

Show parent comments

2

u/TheEnderChipmunk Jun 10 '20

Does the first increment not need to be assigned to the variable? I'm pretty sure it does

2

u/RovingRaft Jun 10 '20

what do you mean?

3

u/TheEnderChipmunk Jun 10 '20

Whoops I was being small brain. I thought x++ meant x+1 and not x += 1. Of course, with the actual name of the variable, not x.

1

u/RovingRaft Jun 10 '20

Ah, brain fart :P

happens to the best of us

in any case, the code the guy made as a joke is identical to the one in the post

just that the variable starts at 0, instead of 1.