Quote:
Originally Posted by Devil_Lord2
I get up to the question mark which then confuses me...
|
The question mark is called the ternary operator. It is basically like an if-statement.
Here it is written in English:
RESULT = BOOLEAN ? DO THIS : OTHERWISE DO THIS;
A boolean is simply a statement or value that is either true or false.
Now I'll show you an example of converting an if-else statement into ternary.
PHP Code:
if (this.counter >= 4) {
findImg(3).rotation = 3;
}else {
findImg(3).rotation = -3;
}
Could essentially be written as the following:
findImg(3).rotation = this.counter >= 4 ? 3 : -3;
The red text is the BOOLEAN. If it's true, it will return/execute whatever is in blue, if it's false, it'll return/execute purple.