Is there a technical reason to use > (<) instead of != when incrementing by 1 in a 'for' loop?

后端 未结 21 2077
小蘑菇
小蘑菇 2020-12-23 19:48

I almost never see a for loop like this:

for (int i = 0; 5 != i; ++i)
{}

Is there a technical reason to use >

21条回答
  •  情深已故
    2020-12-23 20:51

    while (time != 6:30pm) {
        Work();
    }
    

    It is 6:31pm... Damn, now my next chance to go home is tomorrow! :)

    This to show that the stronger restriction mitigates risks and is probably more intuitive to understand.

提交回复
热议问题