Ternary / Conditional Operator in Actionscript 3

Like in many programming languages, Actionscript 3 allows for use of the ternary operator ?:

Let’s take a normal if statement as an example:

1
2
3
4
5
6
7
8
if( score == 10)
{
    win = true;
}
else
{
    win = false;   
}

This could be written in a different way using the ternary operator:

1
win = (score == 10) ? true : false;

So the syntax is: Expression ? statement : statement