r/shittyprogramming • • Feb 21 '20

--> operator

Post image
613 Upvotes

43 comments sorted by

View all comments

Show parent comment

15

u/Mildan Feb 21 '20

Why only for code golf?

It is clearly defining the behavior of the linked program, and not knowing it would evaluate like that would probably be the source of another off-by-one error.

26

u/zephyrus299 Feb 21 '20

Because making it so that's significant behaviour is more likely to result in errors than making distinct statements and makes it harder to modify the code for special cases that may exist in the future.

Like the more clear way of writing this would be

for (x = 9; x >= 0; x--)

This clearly shows that 9 is the first value of x in the loop, it stops when x goes negative and each time x goes down by 1.