Take a conventional if statement like the following:
if(catLegs >= 4){
trace("cat can run!");
}else{
trace("cat has missing legs..");
}
Using a ternary operator it can be condensed into one line following the format:
(condition) ? ifTrueDoThis : ifFalseDoThis;
Rewriting the example above would give us:
(catLegs >= 4) ? trace("cat can run!") : trace("cat has missing legs..");
No comments:
Post a Comment