Conditional operations are so common, languages have evolved an entire family of ways of expressing them. This lets the developer choose the best expression for their needs, whether it be a traditional if/then/else, a switch block, or a ternary operator.

Sometimes, developers don’t make the right choice. Sometimes they don’t make the right choice twice in the same statement. Sergej sends us this:

switch( $_POST["operation"] == "editUser" ? 1 : 2 ) {
      case 1:// editUser
        // SNIP
        break;
      case 2://saveUser
        // SNIP
        break;
      default://endOfTheWorld
        debug( "endOfTheWorld" );
        break;  
   }

At least the developer responsible made sure to cover every possible case.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!