Hi there -
I’d like to have a variable number of “else if” statements. I wrote the following code, but it gets a bunch of errors (which I copied and pasted below the code.
Does anyone know how to do this? Thanks!
void setup(){
int sized = 10;
int randomNum = int(random(sized));
if (randomNum==0) {println("zero");};
for (int x = 1; x<(sized-1); x++){
else if (randomNum==x) {println(x);}
};
}
Syntax Error - Incomplete statement or extra code near 'extraneous input 'else' expecting {'color', HexColorLiteral, CHAR_LITERAL, 'abstract', 'assert', 'boolean', 'break', 'byte', 'char', 'class', 'continue', 'do', 'double', 'final', 'float', 'for', 'if', 'int', 'interface', 'long', 'new', 'private', 'protected', 'public', 'return', 'short', 'static', 'strictfp', 'super', 'switch', 'synchronized', 'this', 'throw', 'try', 'var', 'void', 'while', DECIMAL_LITERAL, HEX_LITERAL, OCT_LITERAL, BINARY_LITERAL, FLOAT_LITERAL, HEX_FLOAT_LITERAL, BOOL_LITERAL, STRING_LITERAL, 'null', '(', '{', '}', ';', '<', '!', '~', '++', '--', '+', '-', '@', IDENTIFIER}'?