Is there a difference between i==0 and 0==i?

后端 未结 8 1410
我在风中等你
我在风中等你 2020-11-27 22:51

First code:

  if(i==0) {// do instructions here}

Second code:

  if(0==i) { // do instructions here }

What

8条回答
  •  囚心锁ツ
    2020-11-27 23:19

    no difference, some people prefer the second one to catch the common mistake of doing assignment (=) instead of equality test (==)

    0 = i would fail at compilation

提交回复
热议问题