是否有我== 0和0 ==我之间的差异?

是否有我== 0和0 ==我之间的差异?

问题描述:

可能重复:结果
   A == B对乙== A,有什么区别

首先code:

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

二code:

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

有什么块之间的区别?

What is the difference between the blocks?

在功能上,是没有区别的。结果
一些开发商preFER写第二格式,以避免错别字分配(如果你错过了一个 = ),所以错字的编译器警告。结果
二是著名的被称为 尤达条件

Functionally, there is no difference.
Some developers prefer writing the second format to avoid assignment typos(in case you miss a =), so that compiler warns of the typo.
The second is famously known as Yoda Condition.

我说没有差别,因为,你不能守护自己对每一个微小的细节,并依靠编译器来放声哭了你。如果你打算写一个 == 你应该期望自己写 == ,而不是 = 。结果
 采用第二种格式只是导致一些不起眼的非可读code。结果
此外,大多数主流的编译器警告的分配的错字的通过 发光代替的平等的一个警告 一旦启用所有的警告(你应该反正)。

I say there is no difference because, you cannot guard yourself against every minuscule detail and rely on compiler to cry out aloud for you.If you intend to write a == you should expect yourself to write a == and not a =.
Using the second format just leads to some obscure non-readable code.
Also, most of the mainstream compilers warn of the assignment instead of equality typo by emitting an warning once you enable all the warnings(which you should anyways).