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

Chapter 5. Boolean() > Example: Shorthand for an if Statement

Example: Shorthand for an if Statement

Sometimes code expressions get very long. To me, this can be a bit irritating, especially when I'm trying to debug something that just stretches out. More than that, when attempting to evaluate a compounded true or false statement, keeping track of the parentheses becomes a bit of a hassle.

However, because you can assign true or false values to objects before an if statement, and use the if statement based on their values, you can save some horizontal space by adding a few lines of code just before an if statement (see Listing 5.3).


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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