“!= true"之间的区别和"== false"? [英] Difference between "!= true" and "== false"?

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

问题描述

在编程语言中,比较!= 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.

这篇关于“!= true"之间的区别和"== false"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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