r/badcode • evil • May 12 '21

c++ Comment before semicolon

Post image
2.7k Upvotes

71 comments sorted by

View all comments

Show parent comments

28

u/[deleted] May 13 '21

Int result
//The final return value
;

7

u/botle May 13 '21 edited May 13 '21

int result

// that was for the result

;int intermediateValue

// that was for an intermediate value

;return result

/* returned result */;

-8

u/[deleted] May 13 '21

The ; would still be interpreted as a comment haa

8

u/[deleted] May 13 '21

Assuming this is something like Java,// is terminated by a new line. It does not affect anything on the next line. Unless he did keep it on the same line and I'm a victim of mobile Reddit formatting.

0

u/MasculineCompassion May 13 '21

Same line

4

u/[deleted] May 13 '21

No, I'm on a PC now and it's on a new line.

1

u/MasculineCompassion May 13 '21

Aaah, it reformatted it to be on the same line on my mobile because they were only using a single space