& quot;!= true& quot之间的差异和& quot ==假& quot ;? [英] Difference between "!= true" and "== false"?

查看:90
本文介绍了& quot;!= true& quot之间的差异和& quot ==假& quot ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编程语言中,比较!= true"和"== false"之间是否存在技术/逻辑差异,如果存在,应在什么情况下选择哪个比较?

Are there any technical/logical differences between the comparison "!= true" and "== false" in programming languages, and if there are, which comparison should be chosen on what occasion?

推荐答案

逻辑上可能存在差异,具体取决于您比较的值类型和使用的语言.例如:

Logically there can be differences depending on the type of value that you are comparing and language you are using. For example:

x == false 暗示 x!= true ,但是 x!= true 并不总是暗示 x == false 因为 x 也可以是一些无意义的值.

x == false implies x != true, but x != true does not always imply x == false because x can also be some nonsense value.

1 +1 = 3 都是 == false != true .

7>cat 都不是 == false != true ,因为这是胡说八道.

7 > cat is neither == false and != true since it is nonsense.

x = null != true ,但不是 == false .

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

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆