本文介绍了"=!"代表什么?接线员呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不小心键入了=!
而不是!=
,这导致了一段时间内未被检测到的系统中的一个巨大错误;从那以后我已经修复了它,但是我对=!
的作用感到好奇.
I accidentally typed =!
instead of !=
that caused a huge bug in a system that went undetected for a while; I have fixed it since but I'm curious as to what =!
does.
我有这样的东西
void foo(int param)
{
int a = 0;
...
if (a =! param)
{
// never got here even when `a` was not equal to `param`
}
...
}
有人可以解释上面的if
语句正在评估什么吗?
Can someone explain what the above if
statement is evaluating ?
推荐答案
此表达式:
a =! param
将值!param
分配给a
. !param
是在布尔上下文中求值的参数的否定版本.
assigns the value !param
to a
. !param
is negated version of param evaluated in boolean context.
赋值运算符返回右侧的值,因此,如果!param
为true,则if (a = !param)
也会执行if
主体.
Assignment operators return the value of the right hand side, so, if (a = !param)
also executes the if
body, if !param
is true.
这篇关于"=!"代表什么?接线员呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!