简体   繁体   English

意外令牌:整数,正在处理2.21

[英]Unexpected token: int, processing 2.21

I'm working with processing 2.2.1, and I am 90% sure that this is syntactically correct. 我正在处理2.2.1,并且我90%确信这在语法上是正确的。 I keep getting an error explaining that it is incorrect with an "unexpected token: int". 我不断收到错误消息,说明它是错误的,并带有“意外的标记:整数”。

void growEllipse(int ellipseHW){
    if(int i = 0; i != width*2; i++){
       ellipseHW = ellipseHW++;
  }

I have tried moving the int to within the function, like so (check below) but then I get an error saying that it is "expecting RPAREN, found ';'". 我试图将int移到函数内,就像这样(请检查下面的内容),但是随后我收到一条错误消息,说它“正在期待RPAREN,找到了';'”。

void growEllipse(int ellipseHW){
  int i;
  if(i = 0; i != width*2; i++){
    ellipseHW = ellipseHW++;
  }
}

This is rather frustrating because it seems syntactically correct. 这相当令人沮丧,因为它在语法上似乎是正确的。 Can anybody help me figure it out? 有人可以帮我解决吗?

It looks like you're trying to use a for loop , not an if statement : 看起来您正在尝试使用for循环 ,而不是if语句

for(int i = 0; i != width*2; i++){
  ellipseHW = ellipseHW++;
}

More info on the for loop can be found in the Processing reference . 有关for循环的更多信息,请参见处理参考

尝试使用“ for”语句代替“ if”语句。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM