本文介绍了是否有我== 0和0 ==我之间的差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  的

首先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).

这篇关于是否有我== 0和0 ==我之间的差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 18:39