这是什么=!操作员? [英] What's this =! operator?

查看:117
本文介绍了这是什么=!操作员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对此代码感到惊讶:

  if(a =!b){//让它处于false b $ b ... 
}

code>从不由值分配。

解决方案

这是两个运算符, = code>!,而不是一个。

  a =!b; 
if(a){
// whatever
}

设置为 b 的逻辑反函数,并测试结果是否为真(或等效地,是否<$

或者可能是 a!= b

的错误类型, code>。


I was surprised by this code:

if (a =! b) { // let it be on false
    ...
}

But a is never assigned by a value. What's this operator about?

解决方案

That's two operators, = and !, not one. It might be an obfuscated way of writing

a = !b;
if (a) {
    // whatever
}

setting a to the logical inverse of b, and testing whether the result is true (or, equivalently, whether b was false).

Or it might be a mistyping of a != b.

这篇关于这是什么=!操作员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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