Loop condition: why “not-equal” instead of “lower-than”

后端 未结 5 1935
攒了一身酷
攒了一身酷 2021-01-04 08:56

I was assigned to work on an Android-Java (real-time game) project with a considerable (partially legacy) code base.

Most of the loops I see are like this (where mjk

5条回答
  •  借酒劲吻你
    2021-01-04 09:45

    I remember encountering this quite a long time ago when coding c++.

    The argument in its favour was that the value of i on exiting the loop was clearer - i.e. it was clear at a glance that on loop exit i would == count.

提交回复
热议问题