• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Part: VII Appendixes > The Conditional Operator

The Conditional Operator

The conditional operator is a slightly optimized way of implementing if-else logic. It's like an if that requires an else, in contrast to the normal if statement, for which the else is optional.

The conditional operator always specifies both a true and a false condition, making it a ternary operator, meaning it has three arguments. Because it is the only operator that always has three arguments, it is sometimes also called the ternary operator. Its format is


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint