【发布时间】:2010-06-18 13:56:33
【问题描述】:
有切换布尔值的捷径吗?
使用整数我们可以进行如下操作:
int i = 4;
i *= 4; // equals 16
/* Which is equivalent to */
i = i * 4;
那么还有一些布尔值(比如 *= 用于整数的运算符)吗?
在 C++ 中:
bool booleanWithAVeryLongName = true;
booleanWithAVeryLongName = !booleanWithAVeryLongName;
// Can it shorter?
booleanWithAVeryLongName !=; // Or something?
在 Java 中:
boolean booleanWithAVeryLongName = true;
booleanWithAVeryLongName = !booleanWithAVeryLongName;
// Can it shorter?
booleanWithAVeryLongName !=; // Or something?
【问题讨论】: