运算符<参数类型未定义 boolean, int [英] The operator < is undefined for the argument type(s) boolean, int
问题描述
我是处理新手,遇到了这个问题.我不断收到以下代码粗体部分的错误消息.我的语法错了吗?
I am new to processing and I am having trouble with this. I keep getting an error message for the bolded part of the code below. Is my syntax wrong?
void block(int x, int y, int s, color tinto) {
fill(tinto);
for (int i = 0; i < 3; i++) {
triple(x, y+i*s, s, tinto);
}
if (0 < i < 3 && 6 < i < 9) { // HERE
tinto = 255;
}
else {
tinto = tinto - 200;
}
}
推荐答案
语法无效,我认为你的表达无论如何都是错误的.你说 i
必须在一个范围内并且在另一个范围内.我想你的意思是说它可能介于两者之间.
The syntax is not valid, and I think you're expression is wrong anyway. You say i
has to be within a range AND within another. I think you mean to write that it could be between one OR the other.
有效语法示例:代替 0 <我<3
,写i>0 &&我<3
.
Example of valid syntax: instead of 0 < i < 3
, write i > 0 && i < 3
.
试试这个:
if ( (i > 0 && i < 3) || (i > 6 && i < 9) )
请注意,以下(显然是您尝试执行的操作)永远不会被评估为 true
,因为它不能在两个范围内.
Note that the following (which is what you were trying to do apparently) will never be evaluated to true
because it cannot be within both ranges.
if ( (i > 0 && i < 3) && (i > 6 && i < 9) ) // incorrect
这篇关于运算符<参数类型未定义 boolean, int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!